Reset MySQL root password

reset mysql root password
reset mysql root password

How to Reset MySQL root password

Sometimes we loose or forget the root password of MySQL database.  Following steps explain how to reset MySQL root password by resetting it.

Step # 1: Stop mysql service

# /etc/init.d/mysqld stop

Stopping MySQL database server: mysqld.

Step # 2: Start mysqld daemon with skip-grant-tables option.  This will start mysql without prompting for a password.

# mysqld_safe --skip-grant-tables & 


[1] 5988
 Starting mysqld daemon with databases from /var/lib/mysql
 mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client and as root user.

# mysql -u root 


Welcome to the MySQL monitor. Commands end with ; or \g.
 Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Step # 4: Now Reset Password

mysql> use mysql;
 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
 mysql> update user set Password=PASSWORD('<new-password>') where user='root';
 Query OK, 3 rows affected (0.00 sec)
 Rows matched: 3 Changed: 3 Warnings: 0 

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

mysql> quit

Step # 5: Stop mysql service

/etc/init.d/mysqld stop

Step # 6: Make sure that all mysql processes are stopped

ps -ef | grep -i mysql

Step # 7: Start the mysql

/etc/init.d/mysqld start

Step # 8: Now connect using user root and password

mysql -u root -p

That’s it! Please post your comments!

Read More:

If you like this post and wish to receive more articles from us, please like our FB page: Button

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at