当前位置: 移动技术网 > IT编程>数据库>Mysql > 将mysql从5.5.25升级到8.0.12

将mysql从5.5.25升级到8.0.12

2019年09月04日  | 移动技术网IT编程  | 我要评论

将mysql从5.5.25升级到8.0.12过程中遇到几个问题,记录如下:

将数据库安装好后,导入原来的数据,启动tomcat,报错unable to load authentication   caching_sha2_plugin,解决办法如下:

   alter user 'root'@'localhost' identified by 'password' password expire never; #修改加密规则 
   alter user 'root'@'localhost' identified with mysql_native_password by 'password'; #更新一下用户的密码 

   flush privileges; #刷新权限 

参考:https://blog.csdn.net/u010026255/article/details/80062153 

网上也有说通过修改my.ini,加入

[mysqld]
default_authentication_plugin=mysql_native_password

经过我的测试,不成功,不知道为什么 。

上述问题解决后,tomcat启动时又遇到:java.math.biginteger cannot be cast to java.lang.long,无法将类型从biginteger转换到long型,网上有说改原始代码的,我查看了原始代码里的mapper文件,里面并没有biginteger和long等字,应该是驱动或者ibatis解析的问题,将驱动升级到和mysql同版本的8.0.12后,上述问题消失,又遇到另一个问题“unsupported major.minor version 52.0”也就是运行环境不支持1.8,我的开发环境和运行环境都是1.7不可能变更到1.8,只能找官方关于mysql-connector-java和jdk版本的关系,官方文档地址为:

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-versions.html

connector/j version jdbc version mysql server version jre supported jdk required for compilation status
8.0 4.2 5.6, 5.7, 8.0 1.8.x  1.8.x  general availability. recommended version.
5.1 3.0, 4.0, 4.1, 4.2 5.6*, 5.7*, 8.0* 1.5.x, 1.6.x, 1.7.x, 1.8.x* 1.5.x and 1.8.x general availability

上图显示8.0以上的connector驱动都需要jdk1.8支持,5.1.x版的驱动程序也是支持8.0.*mysql的,于是下载一个较新的mysql-connector-java-5.1.46(原来5.1.21),再次启动tomcat,无报错了!

项目运行一段时间后,又有报错:

expression #1 of select list is not in group by clause and contains nonaggre

网上查了一下,意思是5.7之后的版本默认情况下开启only_full_group_by sql模式,会导致这个问题,修改my.ini,加入

[mysqld] 
sql_mode=strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution

也就是去掉sql_mode中的only_full_group_by,然后重启mysql,重启tomcat,项目运行正常了。

网上有说通过set @@sql_mode='strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution'修改全局设置的,经我测试不能成功,有人说全局设置只对后来新建的数据库有效。我没有验证。有知道的请留言!

总结就是:生产环境下,不要轻易变更版本!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网