How to Reset mysql Root Password on Linux and Unix ?

How to Reset mysql Root Password on Linux and Unix ?

Step 1: Stop the mysql server using the following command

/etc/init.d/mysql stop


service mysql stop

Step 2: Start the mysql server manually without permission tables which allows us to login as root user without password, using the following command

mysqld_safe —skip-grant-tables

You should see something like this

120425 13:23:00 mysqld_safe Logging to syslog.
120425 13:23:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Step 3: Now open a new terminal window and run the mysql console using the following command

mysql —user=root mysql

Step 4: Finally reset the password from the mysql’s users table, flush privileges, and then exit the MySQL console using the following commands

UPDATE user SET password=PASSWORD(‘NewChoicepassword’) WHERE user=’root’;
flush privileges;

Step 5: Your password has been reset; finally you need the Start MySQL daemon, using the following command

/etc/init.d/mysql start
Service mysql start


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.