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

  1. Logon to your system as an Administrator
  2. Stop the MySQL service
  3. Create a text file with the following SQL command.
  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

    If you have installed MySQL to a location other than c:\mysql, modify the path to mysqld-nt command accordingly

  7. Delete the file created in step 3
  8. Stop the MySQL server from the Command Prompt and restart the MySQL service

You should now be able to connect to the MySQL server using your new password as root.

Reset root password on Unix / Linux

  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.
  4. Save the file as mysql-reset.txt under your home directory
  5. Start MySQL daemon with the –init-file option
  6. Delete the file created in step 3
  7. Kill the MySQL daemon and restart the MySQL daemon

You should now be able to connect to the MySQL server using your new password as root.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }