Sections:

Resetting MySQL Credentials

This assumes that MySQL was installed using the MySQL installer.

Stop MySQL Server

These instructions are derived from https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html section B.3.3.2.1. Be sure to follow the instructions for the Windows installer.

  1. Click Search.
  2. Type services.msc. Press enter.
  3. In the services window, scroll down to MySQL80. Right click on that row. Click Properties.
  4. Copy the line below Path to Executable. Paste the Path to Executable line in a text editor. For reference, the line is

    "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80
  5. Right click on MySQL80 in the Services window. Click Stop.

Reset the MySQL Server Root Account

  1. Click Search.
  2. Type Command Prompt. Right-click on the Command Prompt icon. Choose Run as Administrator.
  3. In the command prompt window, type:

    notepad C:\mysql-init.txt
  4. Choose Yes to create a new file.
  5. Paste the following: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  6. Replace MyNewPass with the credentials you want to use
  7. Store the credentials in a password manager. The username is root.
  8. In Notepad, choose File > Save.
  9. In Notepad, choose File > Close.
  10. In the command prompt window, paste:

    "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file=C:\mysql-init.txt

    If the above command does not work, adjust the path and defaults file to match that of step 4 of the previous section.
  11. The MySQL server should be running with the root account set to the new password.

Confirm

Confirm that the new credentials work.

  1. With the MySQL server still running in the Command Prompt window, click Search.
  2. Type MySQL Workbench. Click on MySQL Workbench 8.0 CE.
  3. Under MySQL Connections, click Local instance MySQL80.
  4. Enter the new credentials for the root account into the password field.
  5. Click OK.

You should be able to connect using the new credentials.

Clean Up

  1. In the Administrator Command Prompt window, press Ctrl and C to stop the MySQL server.
  2. Run: del C:\mysql-init.txt
  3. Run: exit
  4. In the Services Window, right click on MySQL80. Click Start.