April 23, 2008

Reset MySQL root Password

Did you forget your MySQL root password????

Now lets reset our MySQL root password… [no hacking please]

1. Login into your system to be root admin [you can use SSH from another PC in your network].

2. Stop MySQL service,

# /etc/init.d/mysql stop

Or you can use kill service to stop it,

# ps ax | grep mysql

# kill

3. Restart MySQL service without checking permission user,

# /usr/bin/mysqld_safe –skip-grant-tables

In this article we use Fedora, mysqld_safe file maybe different depend on distribution that you use.

4. Open new console, and connect to MySQL server using MySQL client to access MySQL DB.

# /usr/bin/mysql mysql

5. When MySQL prompt appeared. Type this command to reset the password.

UPDATE user SET Password=PASSWORD(‘your_password’) WHERE Host=’localhost’ AND User=’root’;

FLUSH PRIVILEGES;

exit;

6. Stop mysqld_safe service, and restart your MySQL Server.

# /etc/init.d/mysqld start

Its easy, right??? Have a nice try…

No comments: