Reset MySQL root Password


If you have set a root password for MySQL previously, but have forgotten what it was, you can reset the password without much hassle.

 

Reset root password on Windows Systems
  1. Logon to your system as an Administrator
  2. Stop the MySQL service
  3. Create a text file with the following SQL command.
    UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
    
    FLUSH PRIVILEGES;
    
  4. Save the file as mysql-reset.txt under C:
  5. Open a Windows Command Prompt
  6. Start the MySQL server with the –init-file option
    C:mysqlbinmysqld-nt --init-file=C:mysql-reset.txt
    

    If you have installed MySQL to a location other than c:mysql, adjust the above command accordingly

  7. Delete the file created in step 3
  8. Stop the MySQL server from the Command Prompt and restart the MySQL service
  9. You should now be able to connect to the MySQL server using your new password as root.

 

Reset root password on UNIX Systems
  1. Logon to the system as root or as the user that the MySQL daemon runs as
  2. Stop the MySQL daemon process
  3. Create a text file with the following SQL command.
    UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
    
    FLUSH PRIVILEGES;
    
  4. Save the file as mysql-reset.txt under your home directory
  5. Start MySQL daemon with the –init-file option
    mysqld_safe --init-file=~/mysql-reset.txt &
  6. Delete the file created in step 3
  7. Kill the MySQL daemon and restart the MySQL daemon
  8. You should now be able to connect to the MySQL server using your new password as root.

Comments
No Comments Yet

You can be the first to comment!

Leave a Comment





XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>