Mysql—忘记密码重置密码报错

忘记密码后重置密码报错:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
需刷新MySQL的系统权限相关表:mysql> flush privileges;

[root@server1 ~]# vi /etc/my.cnf
[mysqld]
末尾添加
skip_name_resolve    #跳过名字查询
skip_grant_tables      #跳过表格授权
bind-address=0.0.0.0     #所有地址都适用
[root@server1 ~]# systemctl restart mysqld      #重启服务
[root@server1 ~]# mysql    #登录
mysql> set password for root@localhost = password('abc123');   #重置密码
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement  #报错
mysql> flush privileges;        #需刷新MySQL的系统权限相关表
Query OK, 0 rows affected (0.00 sec)     #成功

mysql> set password for root@localhost = password('abc123');    #重置密码
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
[root@server1 ~]# vi /etc/my.cnf
#skip_name_resolve    #注释掉
#skip_grant_tables      #注释掉
#bind-address=0.0.0.0     #注释掉
[root@server1 ~]# systemctl restart mysqld   #重启服务
[root@server1 ~]# mysql -uroot -p    #登录
Enter password:                  #输入密码
mysql>              #成功

你可能感兴趣的:(!)