How to Delete a MySQL Database
Edited by Daniel Leblond, Carolyn Barratt, Teresa, Maluniu and 2 others
Simple steps on deleting a MySQL database.
EditSteps
-
1You'll need a user that has super DELETE privileges on the specific database. If you don't have a specific user to do so you can use your root user.Ad
-
2Using MySQL Command Line Client, go to your terminal view (Command Prompt on Windows), enter "mysql -u yourusernamehere -p".
-
3Enter your password when you are prompted
-
4Once your into the MySQL terminal type "DROP DATABASE databasenamegoeshere;".
-
5You can use "SHOW databases;" and look at your users visible list to confirm that the database has been deleted.Ad
EditTips
- Optionally you can do "DROP DATABASE IF EXISTS databasename;", this will prevent an error from being thrown if the database doesn't exist.
- If you're connecting to a database that isn't localhost you should use mysql -u yourusernamehere -h yourhosthere -p.
- If you don't have access to connect to the high level client you can connect directly to a database with mysql -u name databasenamegoeshere -p.
- If you have the MySQL Workbench, once you login you can double click a connection to go to the database view. Right click the top level (database name) and click drop schema to drop the database.
EditWarnings
- If you use "SHOW databases;" it will only show databases that your user has privileges to see, there could still be others you don't have access to see.
EditThings You'll Need
- MySQL installed on the machine your working on (even if connecting to remote databases)
Article Info
Categories: MySQL
Recent edits by: Maniac, Maluniu, Teresa
In other languages:
Español: Cómo eliminar una base de datos MySQL, Italiano: Come Cancellare un Database MySQL
Thanks to all authors for creating a page that has been read 51,628 times.