- Log on to your system as Administrator.
- Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. 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. - Create a text file containing the following statements. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
WHERE User='root';
FLUSH PRIVILEGES; - Save the file. For this example, the file will be named C:\mysql-init.txt.
- Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
- Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\mysql\bin\mysqld-nt --init-file=C:\\mysql-init.txt
Operation complete ;)
Check here for Mysql documentation.