Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Recovering MySQL root password  (Read 1203 times)

0 Members and 1 Guest are viewing this topic.

nandulalr

  • Guest
Recovering MySQL root password
« on: April 23, 2018, 02:41:15 pm »
Follow the below steps to recover MySQL root password:

- Stop the MySQL server process
Code: [Select]
/etc/init.d/mysql stop

- Start the MySQL process with the –skip-grant-tables option so that it will not prompt for the password.
Code: [Select]
mysqld_safe --skip-grant-tables &

- Connect to the MySQL server as the root user:
Code: [Select]
mysql -u root

- Setup new MySQL root user password
Code: [Select]
mysql> use mysql;

mysql> update user set password=PASSWORD("NEW-PASSWORD") where User='root';

flush privileges;
*Where NEW-PASSWORD is the new password to be used.

- Exit from mysql and stop the mysql service
Code: [Select]
mysql> quit

/etc/init.d/mysql stop

- Start mysql service
Code: [Select]
/etc/init.d/mysql start

- Login to the mysql root account with the new password
Code: [Select]
mysql -u root -p'NEW-PASSWORD'