MySQL 5.7 forgot password after change password

Source: Internet
Author: User
Tags mysql login

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.