社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
经过一次尝鲜mysql8,付出了惨痛代价,特整理“坑”,供后人查询参阅。
1、安装MySQL8时,选择加密方式应选5.7及以前的方式。
mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password。
如果你不幸选择了,sha2,那么参照以下方式修改:
参考:https://blog.csdn.net/weixin_42403773/article/details/80602603
把mysql用户登录密码加密规则还原成mysql_native_password.
这里采用方法2解决,具体操作步骤如下:
1).打开命令行小黑屏,进入MySQL的bin目录,然后输入mysql -u root -p,输入密码
2).然后输入
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限
2、修改JDBC的驱动jar的版本为 8.0.11及以上版本。
把标红的地方(也就是jdbc的包版)变量值,改为8.0.11(及以上)版本。
3、如果出现时区错误。
参考:http://www.cnblogs.com/sunny3096/p/9259274.html
异常提示如:
Could not get JDBC Connection; nested exception is java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
需要去修改链接字符串,或者修改mysql的时区。
方式一:修改数据库url
jdbc:mysql://localhost:3306/springsecurity?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
方式二:修改数据库时区
set global time_zone='+8:00';
这样,mybatis连接mysql8就可以正常使用了
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!