Delete a MySQL Database
To delete a MySQL database, you'll need to use your root user or a user with delete privileges. Enter "mysql -u yourusernamehere -p" in the MySQL terminal, enter your password when prompted, and delete the unwanted database using the "DROP DATABASE database name goes here;" command.
Steps
- You'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.
- Using MySQL Command Line Client, go to your terminal view (Command Prompt on Windows), enter "mysql -u yourusernamehere -p".
- Enter your password when you are prompted
- Once you're into the MySQL terminal type "DROP DATABASE database name goes here;".
- You can use "SHOW databases;" and look at your users visible list to confirm that the database has been deleted.
Tips
- Optionally you can do "DROP DATABASE IF EXISTS database name;", 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 your host here -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 database name goes here -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.
Warnings
- 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.
Things You'll Need
- MySQL installed on the machine your working on (even if connecting to remote databases)
Related Articles
- Create a Database in MySQL
- Retrieve Data from Mysql
- Use MySQL
- Administer MySQL