1.打开数据库,在命令行输入
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root1';
数据库查询表,发现新版使用的,caching_sha2_password ,可能我自己的版本不支持这种格式的密码。
| plugin | authentication_string |
| caching_sha2_password | $A$005$piM&Krp\j/35!8<;HxBixcPjO34yvUXvNgQIPbdNu.E9xREeQDU9UZ1tAN/ |
2.重新运行项目方法后又会报错如下:
Unknown system variable 'query_cache_size'
这是由于数据库connector jar包与你的数据库版本不一致导致的,这是只要修改你的数据库jar包即可
3.修改完成后,重新运行项目方法,又可能报错如下:
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.
这是由于你的数据库的时间与系统时间不符导致的,解决办法如下:
在url 后面加上 serverTimezone=GMT
?characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT
4.最后重新运行即可。