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.
- Click Search.
- Type services.msc. Press enter.
- In the services window, scroll down to MySQL80. Right click on that row. Click Properties.
- 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
- Right click on MySQL80 in the Services window. Click Stop.
Reset the MySQL Server Root Account
- Click Search.
- Type Command Prompt. Right-click on the Command Prompt icon. Choose Run as Administrator.
- In the command prompt window, type:
notepad C:\mysql-init.txt
- Choose Yes to create a new file.
- Paste the following:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
- Replace MyNewPass with the credentials you want to use
- Store the credentials in a password manager. The username is
root
.
- In Notepad, choose File > Save.
- In Notepad, choose File > Close.
- 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.
- The MySQL server should be running with the root account set to the new password.
Confirm
Confirm that the new credentials work.
- With the MySQL server still running in the Command Prompt window, click Search.
- Type MySQL Workbench. Click on MySQL Workbench 8.0 CE.
- Under MySQL Connections, click Local instance MySQL80.
- Enter the new credentials for the root account into the password field.
- Click OK.
You should be able to connect using the new credentials.
Clean Up
- In the Administrator Command Prompt window, press Ctrl and C to stop the MySQL server.
- Run:
del C:\mysql-init.txt
- Run:
exit
- In the Services Window, right click on MySQL80. Click Start.