Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

Because we always forget the root password of mysql.

An old client of mine emailed me a while ago asking about the password of the MySQL server.

I have installed their VICIDIAL Predictive Dialer like a year ago. They only used it for manual dialing using eyebeam :( . Anyhow so I tried to login to the MySQL server using the only password I l know and it didint work! So I have no choice but to reset the root password of the Mysql Server.

Ok what do you need in order to reset or change the root password of MySQL?

1) You need root access to the server. If you dont have it, then you are out of luck! Ask your server administrator to execute the next steps.

2) The reason why you need root access is, for you to be able to stop the MySQL daemon. Here’s how to stop the MySQL daemon in Centos:
service mysqld stop

3) Now the next part is to start the MySQL server and also we need to skip the grant tables because its where the password are stored. Here’s how:
mysqld_safe --skip-grant-tables

You thought you’re done? Not yet! You have to open or connect another ssh session in order to enter MySQL server. As what you are going to experience when you’re going to try this howto, is that you dont see any processes or what ever just the cursor blinking :( . Just leave it at that and open up another connection.

So when you are connected to the shell again, log in to the MySQL server by typing this:
mysql -uroot mysql

And then VIOLA! you are now inside the mysql server and as root too! Let’s change the root password of the MySQL server now. You can do that by typing the following command in the MySQL cli or console. The new password of the MySQL server will be pK@t9l5? . Type this: (Change the pK@t9l5? to the password you want to be specified.)
update user set Password=PASSWORD('pK@t9l5?') where user='root';

Then type this command next.
flush privileges;

Last but not the least. We need to exit from the MySQL console:
exit;

That’s it! You have changed the root password of the MySQL server :) .

Ok don’t forget to stop the process:
mysqld_safe --skip-grant-tables

Then turn on the MySQL server again by typing:
service mysqld start

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Fark
  • LinkedIn
  • Live
  • MSN Reporter
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Leave a comment  

name*

email*

website

Submit comment

CommentLuv badge

Switch to our mobile site