Debug School

rakesh kumar
rakesh kumar

Posted on

Assigning Anonymous Account Passwords

Removing Anonymous Accounts

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');
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode

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)