Common steps:
1. Add a row under Mysqld in My.ini
Skip-grant-tables
2. After restarting MySQL, directly enter, modify the password column directly with sql:
c:\> net stop MySQL
net start MySQL
c:\> MySQL
Mysql>
mysql> use MySQL
Database changed
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
ERROR 1054 (42S22): Unknown column ' Password ' in ' Field list '
3. But failed because the new version of MySQL (5.7 later) This column has been changed to "authentication_string", so in the failure, the correct way is
UPDATE user SET Authentication_string=password (' NewPassword ') where user= ' root ' ; 1 row affected, 1 Warning (0.001 changed:1 warnings:1mysql>
4. Remove the previously joined Skip-grant-tables line from My.ini and restart MySQL to log in with password root
E:\mysql> net stop mysqlmysql service is stopping. The MySQL service has stopped successfully. E:\mysql> net start MySQLMySQL service is starting. The MySQL service has started successfully. E:\mysql>mysql-u Root- pEnter Password:***********Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is2Server Version:5.7.15Copyright (c)+, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type' Help; ' or ' \h ' forHelp. Type ' \c 'To clear the current input statement.mysql>
5. This time is not over, you also need to change the password in normal mode, or kill also done, the following error:
mysql> use mysql1820 (HY000): You must reset your password using ALTER USER statement before exec Uting this statement.
5. And tip very pit Daddy, you have to use Set_password instead of the hint that the alter USER
mysql> SET PASSWORD = PASSWORD (' newpassword '0 rows affected, 1 Warning (0.00 sec) MySQL> Usemy Sqlmysql>database changed
Newly installed MySQL change root password problem in Windows