It looks like you may have one or more anonymous users.
To see how they run this query:
SELECT user,host,password FROM mysql.user WHERE user='';
To verify that you are authenticated as such, run this:
SELECT USER(),CURRENT_USER();
This will show how you tried to log in and how mysql allowed you to log in .
Run these two queries:
DELETE FROM mysql.user WHERE user=''; FLUSH PRIVILEGES;
That should do it !!!
CAVEAT # 1
If this does not work, check /etc/my.cnf for this option:
skip-grant-tables
If it is in my.cnf, uninstall it and restart mysql.
CAVEAT # 2
Something else to look out for is a few root users. Run this:
SELECT user,host,password FROM mysql.user WHERE user='root';
If you define root to have a password and still fall under root, this indicates that there are several root users. There may be these entries in mysql.user
- root @ local
- root@127.0.0.1
- root @hostnameofserver
mysql can allow authentication from any of the root users if the root user does not have a password. This should occur when running SELECT USER(),CURRENT_USER(); , because the output of each function will be displayed as different.
If one root user has an MD5 password and all other root users do not, you can distribute this MD5 password to other root users as follows:
UPDATE mysql.user SET password = ( SELECT password FROM mysql.user WHERE user='root' AND password <> '' ) WHERE user='root' AND password = ''; FLUSH PRIVILEGES;