MySQL8客户端无法连接?
2020-03-08 本文已影响0人
忘记_3a6a
1.MySQL8客户端无法连接?
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;
2.java连接MySQL8问题:
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.Drive
连接时间不同
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: 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.
查询数据库时出错。原因:java.sql。SQLException异常:服务器时区价值”Oйu±e×¼e±¼的识别或代表多个时区。如果希望利用时区支持,必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更特殊的时区值。
- 解决方法:
其中UTC是统一标准世界时间。
完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC
这个是解决中文乱码输入问题
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC