天天看点

将MySQL升级到8.0.x后的遇到到错误及解决

将MySQL升级到8.0.x后的遇到到错误及解决

    • 我为啥升级呢?
    • 安装的时遇到的坑
    • eclipse中启动项目时出错
      • 第一个Error:MySQLNonTransientConnectionException
      • 第二个Error:Loading class...
      • 第三个Error:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized
      • 第四个Error:Public Key Retrieval is not allowed

我为啥升级呢?

将MySQL升级到8.0.x后的遇到到错误及解决

当时我就看到了这张图(/▽\)。。。。

然后刚升级了下其它的软件,感觉顺便把这个也升级了,尝尝鲜,看看两倍速的感觉(当然自己做的小项目里怕是体验不出来了),然后就决定升级了。但是一路坑啊。(原来我用的就是Mysql5.7╮(╯-╰)╭)

安装的时遇到的坑

我下的是Mysql 8.0.13

地址:https://dev.mysql.com/downloads/mysql/

下的是解压版(个人能不用安装就不想用安装版的强迫症(/▽\))

然后问题就来了:

解压后还要初始化,命令是:

mysqld --initialize --user=mysql --console
           

然后我就一直会有错误,导致初始化出问题。

配置好环境变量,然后用cmd管理员权限才成功(没成功的话可能就是没用管理员权限)

初始化出来的临时密码要记起来,最好就安装完及改掉,要不然就麻烦。

eclipse中启动项目时出错

第一个Error:MySQLNonTransientConnectionException

MySQLNonTransientConnectionException: 
Client does not support authentication protocol requested by server; consider upgrading MySQL client
           

错误原因:MySQL的驱动不支持了

解决:下载最新的适合的驱动;

下载链接:https://dev.mysql.com/downloads/connector/j/

将MySQL升级到8.0.x后的遇到到错误及解决

选择平台独立,然后下载。

第二个Error:Loading class…

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.
The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
           

错误原因:原来的驱动‘com.mysql.jdbc.Driver’已被弃用需使用新的驱动’com.mysql.cj.jdbc.Driver’。

解决:将驱动的代码改为新的,我做的一个是SSH的 ,将jdbc.properties中的

jdbc.driver = com.mysql.jdbc.Driver
改为==>
jdbc.driver = com.mysql.cj.jdbc.Driver
           

第三个Error:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized

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.
           

错误原因:它说时区不能识别,需要指定时区

解决:在uri链接上加上时区的参数指定时区。

jdbc.url = jdbc:mysql:///artexam?serverTimezone=UTC
           

第四个Error:Public Key Retrieval is not allowed

当我重启数据库的时候,再次启动项目就报了这个错:

Public Key Retrieval is not allowed
           

解决:在参数上给它带上允许

jdbc.url = jdbc:mysql:///manxc?serverTimezone=UTC&allowPublicKeyRetrieval=true