How to clean up MySQL
Written by Guillermo Garron
Date: 2015-02-22 15:04:32 00:00
How to clean MySQL from not used databases and users?
When you are a tester, and keep proving one application after other, then you end up with a lot of garbage on your MySQL server, that is unused databases and users. There is an easy way to clean it.
Let's connect to the server
mysql -u root -p
Once logged in, list all databases.
mysql> SHOW DATABASES;
Now let's suppose you want to delete a database named wordpress.
mysql> DROP DATABASE wordpress;
And so on with all unused databases, but now it is time for the users, once again first list them all
mysql> SELECT host, user, password from mysql.user;
Let's now delete a users named wordpress_user
mysql> DROP USER wordpress_user;
You are all done, you can now continue to install and uninstall software on your server, just clean MySQL when you finish testing.