Anonymous User

From Hashmysql
Jump to: navigation, search

The default installation of MySQL creates two logins which are "anonymous", meaning that any user can use them without a password.

This causes certain very common problems, with symptoms such as:

  • Access denied for user '@localhost'
  • Creating a user, without specifying user@localhost, and being unable to log in to the local database with that user.
  • Anytime SELECT CURRENT_USER() reports "@localhost".

Some ways to remove these anonymous logins:

  • mysql_secure_installation
    • This is a shell script which will, among other things, delete any anonymous logins, drop the test database and force passwords for root logins.
  • Delete the users manually
mysql -uroot
DELETE FROM mysql.user WHERE user = '';
FLUSH PRIVILEGES;