Saturday, February 16, 2008

Resetting mysql password

  1. Ensure that you have stopped all running instances of mysqld


  2. Create a text file and place the following command
    within it on a single line:


    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');


    Save the file with any name. For this example the file
    will be ~/mysql-init.




  3. Restart the MySQL server with the special
    --init-file=~/mysql-init option:


    shell> mysqld_safe --init-file=~/mysql-init &


    The contents of the init-file are executed at server
    startup, changing the root password. After the server
    has started successfully you should delete
    ~/mysql-init.



  4. You should be able to connect using the new password.

(From site http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html )

No comments: