Resetting a forgotten MySQL root password

  1. Stop mysqld and restart it with the --skip-grant-tables option.
  2. to start use # /usr/bin/mysqld_safe --skip-grant-tables
  3. Connect to the mysqld server with this command:(you may have to use new shell / window for this)
    shell> mysql
  4. Issue the following statements in the mysql client. Replace the password with the password that you want to use.
    mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
        ->                   WHERE User='root';
    mysql> FLUSH PRIVILEGES;
  5. stop mysqld server using service mysqld stop - make sure to stop and restart so that new service will be password protected
  6. restart server with service mysqld start

Leave a Reply

 

You must be logged in to post a comment.

Site map | Blog
Copyright © 2008, COG IT Solutions Pvt. Ltd. All Rights Reserved
XHTML Validated