Skip to Content

Recover MySQL root Password (If Forgotten), Reset Mysql Root Password, Change MySql Root Password

Recover Lost Mysql root Password, Change Mysql Root Password, Lost Mysql Root Password, Reset Mysql Root Password Linux Cammand Line To Recover the Password following steps are required.

Step 1:

# /etc/init.d/mysqld stop 
or
# /etc/init.d/mysql stop 

OutPut: Stopping mysqld: [ OK ]

Step 2:

# mysqld_safe --skip-grant-tables &
OutPut:
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

If no # Prompt come type cntrl +c

Step 3:

# mysql -u root
OutPut: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 4:

 mysql> use mysql;
OutPut: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed

Step 5:

 mysql> update user set password=PASSWORD("NEW_PASSWORD") where User='root';
OutPut: Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0

Step 6:

 mysql> flush privileges;
OutPut: Query OK, 0 rows affected (0.00 sec)

Step 7:

mysql> quit
OutPut: Bye

Step 8 :

# /etc/init.d/mysql start
Or
# /etc/init.d/mysqld start

Step 9 :

Try Logging in now.By typing
mysql -u root -p 
and Type ur NEW_PASSWORD