Reset MySQL root Password

Recently, I forgot the root password for MySQL and went about resetting it as below:

  1. Stop mysqld and restart it with:
    # service mysqld stop
    # mysqld_safe --skip-grant-tables --user=root
    
  2. Connect to the mysqld server with this command:
    sql> mysql -u root
    
  3. Issue the following statements in the mysql client:
    mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
    mysql> FLUSH PRIVILEGES;
    

    Replace “newpassword

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thank You

thanks....
it really works..
coz this command helps me to change my old password...!!!

Post new comment

  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.
Comment