Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Vesta CLI
  • Search

VestaCP api delete database

Questions regarding the Command Line Interface
CLI
Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
xinaidao
Posts: 4
Joined: Tue Jan 28, 2020 12:16 am

Os: Ubuntu 17x
Web: apache + nginx
VestaCP api delete database
  • Quote

Post by xinaidao » Wed Mar 17, 2021 12:20 am

Hello guys.

I need, through an api, to create and delete mysql database.
From what I've been seeing in the documentation, it is possible to create a database via api as shown in the link https://vestacp.com/docs/api/#add_database

My question is whether it is possible to delete the mysql database through this same api. Would anyone know anything about that?
Thank you all
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: VestaCP api delete database
  • Quote

Post by grayfolk » Wed Mar 17, 2021 1:28 am

xinaidao wrote: ↑
Wed Mar 17, 2021 12:20 am
Hello guys.

I need, through an api, to create and delete mysql database.
From what I've been seeing in the documentation, it is possible to create a database via api as shown in the link https://vestacp.com/docs/api/#add_database

My question is whether it is possible to delete the mysql database through this same api. Would anyone know anything about that?
Thank you all
Sure, this is possible. I think you can use this code:

Code: Select all

<?php
// Server credentials
$vst_hostname = 'server.vestacp.com';
$vst_username = 'admin';
$vst_password = 'p4ssw0rd';
$vst_returncode = 'yes';
$vst_command = 'v-delete-database';

$username = 'demo';
$db_name = 'demo_wordpress';

// Prepare POST query
$postvars = array[
    'user' => $vst_username,
    'password' => $vst_password,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => $username,
    'arg2' => $db_name
];
$postdata = http_build_query($postvars);
Note: when you create database it will be created with username prefix: demo_wordpress in this case. For delete database you should use db name with prefix.

Also, see scripts in /usr/local/vesta/bin folder - you can use all those commands via API.
Top

xinaidao
Posts: 4
Joined: Tue Jan 28, 2020 12:16 am

Os: Ubuntu 17x
Web: apache + nginx
Re: VestaCP api delete database
  • Quote

Post by xinaidao » Wed Mar 17, 2021 2:29 pm

Grayflolk,

thank you so much
Top


Post Reply
  • Print view

3 posts • Page 1 of 1

Return to “CLI”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password