Mysql忘记密码

mysql admin 2164℃ 2评论

Mysql 忘记密码

 

 

1.      service mysqld stop

 

2.      mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

 

3.      mysql -uroot

 

4.      use mysql

 

5.      update user set password=password(youpassword) where user=root

       如果是5.7以上   update user set authentication_string=password(youpassword) where user='root'

 

6.      flush privileges

 

 

如果在赋权限出现 以下错误,请查看user表的plugin字段

 

ERROR 1524 (HY000): Plugin '*46432EF49A115120D7735593B5AB51564AC2B832' is not loaded

 

 

 

mysql> select user,plugin from user;

+---------+-------------------------------------------+

| user    | plugin                                    |

+---------+-------------------------------------------+

| root    | mysql_native_password                     |

| root    | mysql_native_password                     |

| root    | mysql_native_password                     |

| root    | mysql_native_password                     |

|         | mysql_native_password                     |

|         | mysql_native_password                     |

| y***g  | *D78B1834F72FB57DE21E49952EBBA9A969B8A459 |

| ****** | *46432EF49A115120D7735593B5AB51564AC2B832 |

+---------+-------------------------------------------+| webosss |                                           | *46432EF49A115120D7735593B5AB51564AC2B832

 

把plugin 更新成mysql_native_password就可以了



7.常见错误:

    a. You must reset your password using ALTER USER statement before executing this statement

      解决方案:重置密码,mysql命令行输入:set password=password(youpassword)

   b. Your password does not satisfy the current policy requirements

      解决方案:mysql命令行输入:set global validate_password_policy=0;

 




加载中...