Question
How do I delete a database from the command line?
Answer
Note: 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.
Warning: The actions below to remove databases permanently deletes them from the server.
- Access your server via ssh as the
rootuser, 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
$userwith 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 following command below to remove the database, where
$databaseis 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.