Sep 022009
 

With lots of server to maintained, sometimes this occasionally happened. how to reset root password you forgotten root password?? seems like chicken egg problem to me 🙂 Don’t worry here’s the solutions First of all you will need to ensure that your database is stopped:

# service mysqld stop

Now we should start the database with –skip-grant-tables which would allow us to connect to it without a password.

# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 1001
Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[1002]: started

Let’s change the root password:

# mysql --user=root mysql
Enter password:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0

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

mysql> exit
Bye  

Now that you’ve done that you just need to stop the temporary unsecure server, so that you can go back to running a secure MySQL server with password restrictions in place. First of all bring the server you started into the foreground by typing “fg”, then kill it by pressing “Ctrl+c” afterwards. start original secure MySQL server

# service mysqld start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

Now everything should be done and you should have regained access to your MySQL database Go ahead and try it 🙂

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 202718 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \q
Bye
# 

done!

 Leave a Reply

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=""> <s> <strike> <strong>

(required)

(required)

*