Steps to expire or reset the password of mysql under windows:
- Stop the mysql service (run services.msc, find mysql, and stop)
- Modify the my.ini file and add a newline at the end of the file: skip-grant-tables
- cmd enters the installation bin directory, mine is installed on the c drive. (If you don't remember where it was installed, you can find the mysql service by running services.msc and double-click to view the directory): C:\>cd "Program Files\MySQL\MySQL Server 5.7\bin"
- Enter the command: mysql -u root -p, when Enter password appears, press Enter directly. When mysql appears, the operation is successful.
- Input: use mysql;, output "Database changed" is successful (be careful not to drop the semicolon)
- Update the password to 123456, enter the command: update mysql.user set authentication_string=password('123456') where user='root'; (don't drop the semicolon, the command I entered at the beginning is: update user set password=password( "123456") where user="root"; this is wrong, an error is reported: ERROR 1054 (42S22): Unknown column 'password' in 'field list')
- Execute the following command: flush privileges; (note that the semicolon cannot be dropped)
- Exit, enter the command: quit;
- Run services.msc to start the mysql service.