1. Modify Login Settings
VIM/ETC/MY.CNF #或/etc/mysql/my.cnf [mysqld] Skip-grant-tables #新加
2. Restart MySQL Service
3, direct MySQL login, and change the password
Update mysql.user set authentication_string=password (' new password ') where user= ' root '; # 5.7 In the Save password field is this, desc first look at the Save password field. Other versions are generally modified as follows #mysql> update mysql.user set password = password (' New-password ') WHERE User = ' root ' ; #如遇到报错 You must reset your password using alter user statement before executing this statement. reason is that the password is valid and needs to be executed 1. ALTER USER ' root ' @ ' localhost ' PASSWORD expire never; #设置密码永不过期, change back to default method alter user ' root ' @ ' localhost ' password expire default 2. or set global default_password_lifetime=0 or write directly in the configuration file, the expiration time of 0 means never expires, the global effect. Recommended Chinese law only specific user password flush privileges; #使用update修改密码必须要执行此步或者set password=passwprd (' New password '); #不须刷新授权表, Full format SET PASSWORD FOR ' root ' @ ' localhost ' =password (' newpassword ');
4. Modify the configuration file
Delete
Skip-grant-tables
Restart Service
MySQL 5.7 forgot password after change password