springmvc mysql5.x 替换成mysql8
环境:center os 6.5 mysql 8原来工程用的是mysql5.0,现在要用mysql8
什么都不变会报以下错误:
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/testdb?useUnicode=true&charaterEncoding=utf-8
上网查询,修改配置文件如下“
<property name="driverClassName">
<!-- com.mysql.jdbc.Driver 换成 com.mysql.cj.jdbc.Driver -->
<value> com.mysql.cj.jdbc.Driver</value>
</property>
<property name="url">
<!-- 加上时区参数 -->
<value>jdbc:mysql://localhost:3306/gimsdb?serverTimezone=UTC&useUnicode=true&charaterEncoding=utf-8</value>
</property>
仍旧报错,jdbc驱动程序包替换
删除mysql-connector-java-5.1.6-bin.jar,添加mysql-connector-java-8.0.11.jar
ok成功
*因为mysql版本更新,有些sql可能会报错,需要单独处理
grant all privileges on *.* to 'admin'@'localhost';
一开始还下载了mysql workbench6.3,结果连接mysql8失败,报组件错误
安装mysq8包括workbench,用mysql8的workbench连接mysql5.0的数据库,结果也不兼容,报bad handshake