Friday, October 22, 2010

How to Reset the Root Password in MySQL


For those who have had the annoyance of losing their root password in MySQL, or  will loose it yet, here's a tip which can save the day.

Stop or kill the MySQL service

# killall mysqld    or    # service mysqld stop

Start MySQL in safe mode:

# mysqld_safe --skip-grant-tables &

log in using the mysql client:

# mysql

Access the MySQL database

> use mysql;

Setting new MySQL root password:

> update user set password = password ('type your new password here') where user = 'root' and host = 'localhost';

Reload privileges by typing:

> flush privileges;

Exit MySQL:

> quit

Restart MySQL  in normal mode:

# service mysqld stop

And finally, let's start with the new MySQL root password:

# service mysqld start

And voila, your new root password and access granted to the database again.

Sharing is Caring:
By Alessandro Ebersol with No comments

0 comments:

Post a Comment

  • Popular
  • Categories
  • Archives