Apr 072007
 

Sponsored Link

By default, MySQL Server will be installed with root superuser without any password. You can connect to MySQL server as root without requiring password or by keying in blank password. However, if you have set the password for root and forget or unable to recall the password, then you will need to reset the root password for MySQL.

Login as root to the Unix-like (Unix, Linux or BSD) machine with the MySQL server.

Stop the MySQL server by using either of the following command

#/etc/init.d/mysql stop

Now you need to Start MySQL server without password

# mysqld_safe --skip-grant-tables &

Connect to mysql server using mysql client with the following command

# mysql -u root

Now you should be having mysql prompt

mysql>

Now you need to Setup new MySQL root user password

mysql> use mysql;

mysql> update user set password=PASSWORD("newrootpassword") where user='root';

mysql> flush privileges;

mysql> quit

Note: Replace newrootpassword with the new root password for MySQL server. Flush Privileges is needed to making the password change effect immediately.

Now you need to Stop MySQL Server using the following command

# /etc/init.d/mysql stop

Test Your New Mysql root password

First you need to start mysql server using the following command

# /etc/init.d/mysql start

# mysql -u root -p

Now it will prompt for root password and enter your new root password

Sponsored Link

 Posted by at 6:53 pm

  10 Responses to “Recover MySQL Database root password”

  1. Thank you thank you thank you… major lack of help for Debian in this area.

  2. Sweeet, it works, been look all over the net for hours for this, this is awesome. thanks so much…

  3. hi, I need help.is there anyone can help me on ubuntu MYSQL issue?

  4. What kind of help do you need with Ubuntu, maybe i can help

  5. Thanks very much!!

  6. It works great!
    thank u

  7. Thank You!

  8. Here’s another way you can reset the mysql root password using mysqladmin tool provided within mysql package

    mysqladmin -u root password

  9. 120316 07:59:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    120316 07:59:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

    Help This ..

  10. THANKS this is the only one that woked!! debian 6 x86

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>