Tuesday, January 13, 2009

Reset MySql root password


Well, it had been quite sometime since I used MySql and then for some demo I had to. But, the problem was that I had forgotten the password and googling for help told me that I am not the only stupid in this universe Embarassed. Well here is the solution to the problem:





  1. Stop your MySql service.




  2. Open and command window.




  3. cd to the MySql bin directory (if the MySql bin is not added to your path).




  4. Now run this command
    mysqld-nt.exe --skip-grant-tables &




  5. Now open another command window and if required again cd to the MySql bin window and run this command
    mysql -u root mysql




  6. In MySQL command line prompt run the following commands:
    UPDATE user SET password=PASSWORD("password1234") WHERE user="root";
    FLUSH PRIVILEGES;




  7. Yippe... the root password is reset to "password1234" and MySQL will now
    know the privileges and you'll be able to login with your new password.





 Of course this set of instruction is for Windows and MySQL 5. For Linux, I guess (am not sure, so please look around in the mysql bin directory for correct file name), the command in step 4 will change to "mysqld_safe --skip-grant-tables &" (based of googled results). Rest I believe should be same. In case someone I missed something or you have instruction for other OS/ mysql versions, let me know, will be happy to update it.



 

No comments:

Post a Comment