To assign passwords to the anonymous accounts, connect to the server as root, then use either SET PASSWORD or UPDATE.
To use SET PASSWORD on Windows, do this:
$> mysql -u root -p
Enter password: (enter root password here)
mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('new_password');
To set the anonymous-user account passwords with a single UPDATE statement, do this (on any platform):
$> mysql -u root -p
Enter password: (enter root password here)
mysql> UPDATE mysql.user SET Password = PASSWORD('new_password')
-> WHERE User = '';
mysql> FLUSH PRIVILEGES;
The FLUSH statement causes the server to re-read the grant tables. Without it, the password change remains unnoticed by the server until you restart it.
Top comments (0)