ERROR [Druid-ConnectionPool-Create-159475521] - create connection SQLException, url: jdbc:mysql://localhost:3306/emp?serverTimezone=UTC, errorCode 1045, state 28000
java.sql.SQLException: Access denied for user ‘Fang’@‘localhost’ (using password: YES)
经过查询 数据库1045错误,是密码或者用户名错误。
使用了spring,配置文件中的username不能叫username,spring会默认username是你的计算机名,解决办法,把username改个名字即可。
或在每个配置信息前面加上 jdbc. 即可(jdbc.username)。
参考博客https://blog.csdn.net/qq_42435377/article/details/107841196
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=UTC
jdbc.url=jdbc:mysql://localhost:3306/emp?serverTimezone=UTC
UTC,简称世界统一时间,跟北京时间相比,比北京早8个小时,也就是说,北京2020年3月20日18点的时候,UTC时间为2020年3月20日10点
如果你用编译器连接数据库,定义了serverTimezone=UTC,那么在你编译器上执行的SQL语句,会先以UTC时区进行存储,发送到MySQL,然后MySQL以本地时区进行转换,就会导致,执行时间比从编译器上的执行时间早8个小时,导致,同一段SQL语句,在mysql直接执行,与编译器执行,结果不同,因为时间相差8个小时
解决方式
将属性设置为
serverTimezone=Asia/Shanghai
参考博客https://blog.csdn.net/baidu_38837718/article/details/104981617