Recover the MySQL root password.

To recover the MySQL root Password, please follow these steps:

1. Stop the MySQL server process.

root# /etc/init.d/mysql stop

2. Start the MySQL process with the –skip-grant-tables option, so that it will not prompt for a password.

root# mysqld_safe --skip-grant-tables &

root@mad:/home/user# mysqld_safe –skip-grant-tables &
[1] 23126
root@mad:/home/user# 140729 11:09:49 mysqld_safe Logging to syslog.
140729 11:09:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3. Connect to a MySQL as the root user.

root# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 5.5.38-0+wheezy1-log (Debian)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
mysql>

4. Set the new password for the MySQL root account.

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-PASSWORD") where user='root';
mysql> flush privileges;
mysql> quit

5. Exit and then stop and start or restart the MySQL server.

root# /etc/init.d/mysql restart

Leave a Reply

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

*