1.) stop mysql service from start menu > services > mysql
2.) Create a text file containing the password-assignment statement on a single line and replace the password with a new password you want to set.
>> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’;
3.) save this file as
mysql-init.txt inside the C drive.
4.) Open CMD as administrator from the start menu > CMD > right click on command prompt > run as administrator
5.) Start the MySQL server with the
init_file system variable set to name the file (notice that the backslash in the option value is doubled)
>> c:\> cd “C:\Program Files\MySQL\MySQL Server 5.7\bin” –>(set MYSQL bin from where you have installed MYSQL)
>> C:\> mysqld –init-file=C:\\mysql-init.txt
6.) Once the server has started successfully, delete
You should able to login to MYSQL with a new password, if you are still not able to login, you can try the below statement.
UPDATE mysql.user SET authentication_string = PASSWORD(‘MyNewPass’), password_expired = ‘N’
WHERE User = ‘root’ AND Host = ‘localhost’;