If you set a root password previously but have forgotten what it was, you can set a new password. The following procedure is for Windows systems. You must be logged in to Windows as a user with administrative privileges, then follow these steps:
1. Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager:
Start Menu -> Control Panel -> Administrative Tools -> Services
2. Then find the MySQL service in the list, and stop it. If your server is not running as a service, you may need to use the Task Manager to force it to stop.
3. Open a console window to get to the command prompt:
Start Menu -> Run -> cmd
Assuming that you installed MySQL to ‘C:\Program Files\MySQL\MySQL Server 8.0’. If you installed MySQL to another location, adjust the following commands accordingly. At the command prompt, execute this command:
C:\> cd "C:\Program Files\MySQL\MySQL Server 8.0\bin" C:\> mysqld --skip-grant-tables --skip-networking --enable-named-pipe
The –skip-grant-tables parameter will bypass reading the permissions tables for the MySQL Server; this will allow any user to connect without using a password with full access to all tables. The additional –skip-networking parameter reduces the security risk by stopping the server from accepting connections via TCP/IP; instead named pipes are enabled using –enabled-named-pipe. Named pipes are only available on NT-based systems so TCP/IP must be used for the other Windows OSes. If you are concerned about security you should use a firewall to block external access to the server during this time. Keeping the first console window open, open a second console window and execute the following commands (type each on a single line):
C:\> C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin -u root flush-privileges password "newpwd" C:\> C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin -u root -p shutdown
Replace ‘newpwd’ with the actual root password that you want to use. The second command will prompt you to enter the new password for access. Enter the password that you assigned in the first command.
Once you have stopped the MySQL server, restart it in normal mode again. If you run the server as a service, you can start it from the Windows Services window. If you start the server manually, use whatever command you would normally use. You should now be able to connect using the new root password.
One way to reset the root password on Windows is to follow the procedure mentioned on the manual in link below.