Introduction
This article aims to assist you with removing databases from the command line using cPanel's built-in UAPI tools. Before removing any databases for any users we highly recommend you create backups of the databases using the "mysqldump" command with the instructions in the following article:
Procedure
The actions below to remove databases permanently deletes them from the server, so please check with a Systems Administrator if you are uncertain if a database is necessary for any users on your server.
Additionally, we do not recommend using the MySQL command line as this breaks certain cPanel functionality, such as database mapping. Please only use the API or cPanel UI to create or delete the MySQL database and/or users.
- Access your server via ssh as the root user, or log into the WHM and access the Terminal
- List the databases for the cPanel user in question. You can do this by using the UAPI command, replacing $user with the username of the account you wish to list the databases of:
[root@server]# uapi --user=$user Mysql list_databases
---
apiversion: 3
func: list_databases
module: Mysql
result:
data:
-
database: example_test1
disk_usage: 0
users: []
-
errors: ~
messages: ~
metadata:
transformed: 1
status: 1
warnings: ~ - Run the command below to remove the database, where $database is the name of the database taken from the output of the list above:
uapi --user=$user Mysql delete_database name=$database
Comments
0 comments
Article is closed for comments.