From time to time it happens that mysql password for root user gets lost and you are required to reset mysql password. here’s how it’s done:
A Linux or Windows machine running mysql server.
The following process will teach you how to reset mysql password for root user (or any other user) on both Windows and Linux.
Alternatively, on any platform, you can set the new password using the mysql client (but this approach is less secure).
- Stop mysqld and restart it with the
option. This enables anyone to connect without a password and with all privileges. Because this is insecure, you might want to use
--skip-grant-tablesin conjunction with
--skip-networkingto prevent remote clients from connecting.
- Connect to the mysqld server with this command:
- Issue the following statements in the mysql client. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass')->
FLUSHstatement tells the server to reload the grant tables into memory so that it notices the password change.
You should now be able to connect to the MySQL server as
root using the new password. Stop the server, then restart it normally (without the
No Comments Yet