MySQL/Security – Cleaning up post-install

A default install of MySQL has anonymous users and root users with access via ‘%’ (all outside hosts) and a generally useless ‘test’ database.
 The best method to do this is to execute the following at the shell prompt:

mysql_secure_installation

If this feature is not available, simply execute the following set of queries in MySQL:

DROP DATABASE `test`;
DELETE FROM `mysql`.`user` WHERE `User` = '';
DELETE FROM `mysql`.`user` WHERE `User` = 'root' AND `Host` != 'localhost';
FLUSH PRIVILEGES;