Steps
- Stop MySQL server
1 | # cd to /etc/init.d check your mysql service name, in the original post is mysql but mine is mysqld |
- Restart Mysql with
--skip-grant-tables
option
1 | sudo mysqld_safe --skip-grant-tables & |
- Connect to MySQL server using the mysql client
1 | mysql |
- Reload the grant tables so that account-management statements work
1 | FLUSH PRIVILEGES; |
- Change the
'root'@'localhost
account password. Replace the password with the password that you want to use.
1 | ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; |
- Try to connect to MySQL using your new password
1 | mysql -u root -p |
Something else
- Check MySQL status, start/stop MySQL service
1 | service mysqld status |
Reference
About this Post
This post is written by Andy, licensed under CC BY-NC 4.0.