MySQL8遇到的问题记录

问题1:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

问题描述:

[root@loaclhost ~]# mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@loaclhost ~]# mysql -u root  -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决办法:

1、修改/etc/my.cnf,不使用密码登录

加上skip-grant-tables,保存

重启mysql :systemctl restart mysqld

2、不用密码登录

MySQL8遇到的问题记录_第1张图片

3、ALTER USER 'root'@'%' IDENTIFIED BY '123456';

如果报:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

输入:flush privileges;

4、再次输入:ALTER USER 'root'@'%' IDENTIFIED BY '123456';

提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

(此处参考后面的4、修改简单权限)

5、再次修改密码:ALTER USER 'root'@'%' IDENTIFIED BY '123456';

6、刷新权限
mysql> flush privileges;

7、退出mysql,清除my.cnf的skip-grant-tables后重启mysql
systemctl restart mysqld

最后,再次登录,输入密码可登录

 MySQL8遇到的问题记录_第2张图片

 问题2:ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'

解决办法:

按照以下步骤执行:

进入mysql库

use mysql;

刷新权限

mysql> flush privileges;

清空密码

mysql> UPDATE user SET authentication_string="" WHERE user=“root”;

刷新权限

mysql> flush privileges;

设置root的新的密码

mysql>alter user’root’@’%’ IDENTIFIED BY 'test123 ';

刷新权限

mysql> flush privileges;

退出mysql,清除my.cnf的skip-grant-tables后重启mysql

systemctl restart mysqld

问题3:ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation

解决办法:

#给root用户授权

grant system_user on *.* to 'root';

 

你可能感兴趣的:(mysql,数据库,java)