Database FAQ

[toc]

Why can all of my users see a database named "test"?

MySQL, by default, comes with a database named test; unfortunately, all users are granted access to that database. Also, in some cases, users can be granted permission by default to all databases beginning with the string "test".

We've seen cases where users used the test database to store data for their applications, rather than creating a new database. Problems occurred when other users, not realizing that was production data, made changes to or deleted the data in the test database.

The simplest way to prevent that is to remove the pre-existing permissions MySQL grants to that database.

Note that we recommend running this command only on a fresh installation (ie, before adding any Virtual Servers to your system); otherwise it can remove legitimate permissions of users to databases beginning with the name "test".

To remove permissions to the test database, and others beginning with "test", log into your server over SSH, and run this command:

mysql -u root -p

When prompted, enter your MySQL root password.

Once you're at the MySQL prompt, run the following:

DELETE FROM mysql.db WHERE Db LIKE 'test%';
FLUSH PRIVILEGES;