How to reset MySQL root password in Linux console (SSH)
To reset MySQL root password you should log in as root to your Linux server, stop MySQL service, start it without password and permission checks, log in as root without authorization, update password and restart MySQL server. Now more info.
There are 6 steps:
- Log in as root (not sudo) to your Linux server
- Stop MySQL Service
service mysql stop
- Start MySQL in safe mode - without password and permission checks
mysqld_safe --skip-grant-tables &
If it's halted, press [Enter]
- Connect to MySQL as root without authorization:
mysql -u root mysql
- Set new password for root Run using Update statement and set privileges using FLUSH PRIVILEGES. Don’t' forget to write ";" in the end of each command.
UPDATE user SET password=PASSWORD('MY_NEW_PASSWORD') WHERE user='root';
FLUSH PRIVILEGES;
- Restart the MySQL service.
service mysql restart