~ read.

How to reset password in MySQL server on Linux and Mac OS machine

It happed to me few times, so i decided to write it down for myself for the future. Sometimes i get back to some server or working machine where MySQL was setup long time ago. It's pretty frustrating when you can't get in because of wrong credentials. So, here's a way how to fix it easily .

First you need to stop MySQL server :

sudo /usr/local/mysql/support-files/mysql.server stop

Then we need to start it in safe mode

sudo mysqld_safe --skip-grant-tables

This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:

mysql -u root

Now we can change password for root user for a new password :

UPDATE mysql.user SET Password=PASSWORD('enter-your-password-here') WHERE User='root';
FLUSH PRIVILEGES;

That's it! Now just start mysql server and enjoy:)

sudo /usr/local/mysql/support-files/mysql.server start
comments powered by Disqus
comments powered by Disqus