How to reset MySQL root password without existing password in Windows VPS?

It's pretty simple to reset the MySQL user account  password using SET PASSWORD syntax when you know the existing password. If you assigned a root password previously, and now you cannot recall it, you'll have to take some additional steps to assign a new root password. Following instructions will assist you to reset the MySQL password for Windows system without specifying the previous password.

  1. Login to your Windows system with Administrator user.

  2. If MySQL server is running, you will have to stop it first. For the MySQL server running as a Windows service, go to Start → Administrative Tools → Services. Find the MySQL service in the list and stop it. If MySQL server isn't running as a Windows service, use the Windows Task Manager to stop it.



  3. Open a notepad and create a text file and paste one of the following password assignment statements on a single line. In this statement, replace the New-Password with the password that you want to use.

    Write the following statement in text file for MySQL 5.7.6 and later

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'New-Password';
    Write the following statement in text file for MySQL 5.7.5 and earlier

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('New-Password');
  4. Save this file and note down the file path. For this example, we have stored this file at C:\password-assign-statement.txt.

  5. Open a command prompt, from Start → Run → type cmd in run menu and hit enter.

  6. At the command prompt, start the MySQL server with the special --init-file option. If you've installed MySQL server to a different location, be sure you adjust the MySQL installation path in the first command. Similarly, replace your own password assignment statement file path (we created in step #3) in the second command.

    cd "C:\Program Files\MySQL\MySQL Server 5.6\bin"
    mysqld --init-file=C:\\password-assign-statement.txt.

    As soon you apply the above commands, MySQL server will execute the statement stored in the file password-assign-statement.txt with --init-file option at startup. It will change the password of root user account with the password you mentioned in the file.

    If you installed MySQL server using the MySQL Installation Wizard, specify a --defaults-file option as follows.

    mysqld
    --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 5.6\\my.ini"
    --init-file=C:\\password-assign-statement.txt.
  7. Once MySQL server is started successfully, try to connect to the MySQL server with root account using the new password. Now you should be able to connect to MySQL server with the new password.

  8. Again stop the MySQL server and restart it normally. If you are running the MySQL server as a Windows service then start it from the Windows Services.


  • 3 Users Found This Useful

Was this answer helpful?

Related Articles

How to resolve “mcrypt extension is missing. Please check your PHP configuration” error in phpMyAdmin?

This article will guide you on how to resolve the “mcrypt extension is missing. Please check your...

How to Install MetaTrader in Windows VPS?

Following article will assist you to install MetaTrader Trading Software in Windows VPS. We...

How to Open Ports in Firewall on Windows Server 2008 R2?

Following article will assist you to open ports in Firewall on Windows VPS with Windows Server...

How to install Xojo Apps on the Windows VPS?

This article will assist you how to install Xojo Apps on Windows Server.Xojo is a object oriented...

Common CollectionsMax Issues With Possible Solutions :: Hosted on Windows VPS

CollectionsMAX is a desktop based debt collection software suite that runs on the Windows...