mysql升级8.0后遇到的坑

18-04-21 21:20 字数 1595 阅读 17365 已编辑

听说mysql8的性能提升了很多,对于我这种喜欢把所有软件升级到最新版的人来说,二话不说直接升级。(因为用户不多所以就是这么任性)。升级的过程不可能一帆风顺,本文记录一些遇到的坑,希望对大家有所帮助。

坑一

首先在配置mysql的yum源的rpm包的时候报了如下的错。

$ rpm-Uvh http ://repo.mysql.com/mysql80-community- release-el7-1.noarch.rpm

error: Failed dependencies :
mysql57-community- release conflicts with mysql80-community- release-el7-1.noarch

mysql.png

解决方法一:使用rpm -qa 查找已安装包

$ rpm -qa | grep mysql

mysql57-community- release-el7-11.noarch

然后卸载对应包

$ rpm-e--nodeps mysql57-community- release-el7-11.noarch

解决方法二:增加--nodeps --force 参数

$  rpm-Uvh http ://repo.mysql.com/mysql80-community- release-el7-1.noarch.rpm --nodeps --force

坑二

安装完成后进入数据库show databases;、或者尝试更改权限时报错

ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
Table 'mysql.role_edges' doesn't exist

解决方法

mysql_upgrade -u root -p;

坑三

在客户端成功连接数据库之后,发现项目里的pdo连接mysql又报错了。

Next PDOException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client [caching_sha2_password] in /vendor/yiisoft/yii2/db/Connection.php:687

这个错可能是mysql默认使用caching_sha2_password作为默认的身份验证插件,而不再是mysql_native_password,但是客户端暂时不支持这个插件导致的。官方文档说明

In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password. For information about the implications of this change for server operation and compatibility of the server with clients and connectors, see caching_sha2_password as the Preferred Authentication Plugin.

在MySQL 8.0中,caching_sha2_password是默认的身份验证插件,而不是mysql_native_password。有关此更改对服务器操作的影响以及服务器与客户端和连接器的兼容性的信息,请参阅caching_sha2_password作为首选身份验证插件。

解决方法

编辑my.cnf文件,更改默认的身份认证插件。

$ vi /etc/my.cnf

[mysqld]中添加下边的代码

default_authentication_plugin=mysql_native_password

然后重启mysql

$ service mysqld restart

网站终于正常打开了。。。


mysql_@.png

4人点赞>
关注 收藏 改进 举报
10 条评论
排序方式 时间 投票
dajiang

佩服题主追求技术

Up骚年
太抬举了,也是不求甚解啊。
zousaisai

😇😇😇😇😇

zousaisai

你咋就则么及时哩

Up骚年
😆喜欢尝鲜。。。
Up骚年
mysql8.0默认编码就是utf8mb4,完美支持emoji。😆
请登录后发表评论
站长 @ 十七度
文章
380
粉丝
23
喜欢
190
收藏
31
排名 : 1
访问 : 127.85万
私信