Centos7 MySQL8.0.16修改 root% 用户密码时遇到如下错误:
解决如下:
修改mysql登录设置
[root@localhost ~]# vim my.cnf
在[mysqld]段中加入
skip-grant-tables
保存之后重启mysql服务
[root@localhost ~]# service mysqld restart
登录mysql
[root@localhost ~]# mysql -u root -p
登录后先刷新一下(不然会报错 :ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement)
mysql> flush privileges;
修改密码
mysql> use mysql;
mysql> alter USER 'root'@'%' IDENTIFIED BY '要修改的密码';
再刷新一下
mysql> flush privileges;
删除 skip-grant-tables
重启mysql