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:

  1. Log in as root (not sudo) to your Linux server
  2. Stop MySQL Service

service mysql stop

 

  1. Start MySQL in safe mode - without password and permission checks

mysqld_safe --skip-grant-tables &

If it's halted, press [Enter]

 

  1. Connect to MySQL as root without authorization:

mysql -u root mysql

 

  1. 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;

 

  1. Restart the MySQL service.

service mysql restart

 



MarkiMarta.com. Notes of web-specialist
Since 2009
18+
Get records with empty binary items

There's a column Photo with type "Image" in MS SQL table (database – MS SQL Server 2008 R2). The task...

Close