How to Reset/Recover MySQL root Password on Linux (RHEL/Centos 6.x)

How to Reset/Recover MySQL root Password Step by Set on Linux (RHEL/Centos 6.x) : 

Use the below steps to reset/recover a MySQL root password :

Step 1. Log in as root user.

Step 2. Stop the mysql service if service is running.

# /etc/init.d/mysqld stop


# service mysqld stop

Output :

Stopping mysqld:             [  OK  ]

Step 3. Started MySQL in safe mode.

# mysqld_safe --skip-grant-tables &


160924 15:28:01 mysqld_safe Logging to ‘/var/log/mysqld.log’.

160924 15:28:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Step 4. Connect to MySQL Server with command



Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MariaDB connection id is 1

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

Step 5. Use mysql database for change password.

mysql>Use mysql;

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

mysql> flush privileges;

mysql> exit;

Step 6. Stop MySQL in safe mode.

# /etc/init.d/mysql stop


# service mysqld stop

Output :

14653 13:42:12 mysqld_safe mysqld from pid file /var/run/mysqld/ ended

Stopping mysqld:                                           [  OK  ]

[1]+  Done                    mysqld_safe –skip-grant-tables

Step 7.  Start MySQL server

# /etc/init.d/mysql start


# service mysqld start

Step 8.  Log in with the new password

# mysql -u root –p

Leave a Reply

Your email address will not be published. Required fields are marked *