B.3.3.2.3 Resetting the Root Password: Generic Instructions
The preceding sections provide password-resetting instructions specifically for Windows and Unix and Unix-like systems. Alternatively, on any platform, you can reset the password using the mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such as ALTER USER and SET PASSWORD. Because this is insecure, you might want to use --skip-grant-tables in conjunction with enabling the skip_networking system variable to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use. To change the password for a root account with a different host name part, modify the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally (without the --skip-grant-tables option and without enabling the skip_networking system variable).
If the ALTER USER statement fails to reset the password, try repeating the procedure using the following statements to modify the user table directly:
UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass')
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
B.3.3.2.3 Resetting the Root Password: Generic Instructions
The preceding sections provide password-resetting instructions specifically for Windows and Unix and Unix-like systems. Alternatively, on any platform, you can reset the password using the mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables
option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such asALTER USER
andSET PASSWORD
. Because this is insecure, you might want to use--skip-grant-tables
in conjunction with enabling theskip_networking
system variable to prevent remote clients from connecting.Connect to the MySQL server using the mysql client; no password is necessary because the server was started with
--skip-grant-tables
:In the
mysql
client, tell the server to reload the grant tables so that account-management statements work:Then change the
'root'@'localhost'
account password. Replace the password with the password that you want to use. To change the password for aroot
account with a different host name part, modify the instructions to use that host name.You should now be able to connect to the MySQL server as
root
using the new password. Stop the server and restart it normally (without the--skip-grant-tables
option and without enabling theskip_networking
system variable).If the ALTER USER statement fails to reset the password, try repeating the procedure using the following statements to modify the user table directly: