java mysql常见问题

1.com.alibaba.druid.pool.DruidDataSource : create connection error, url: jdbc:mysql://

1)未开启远程操作权限

win+R->cmd进入登录自己的mysql:
输入命令:mysql -u root -p ****(输入自己的密码)
输入远程命令:GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;(输入自己的用户名和密码)
刷新:flush privileges;

  

2)需要在项目的application.yml配置中加上:(遇到The server time zone value '�й���׼ʱ��' is unrecogni同理)

&useSSL=false&serverTimezone=UTC

  

3)

 

 

2.Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 

整合spring boot项目过程中出现的,用了最新的mysql 连接驱动

application-dev.properties

spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

需要将 com.mysql.jdbc.Driver  改为  com.mysql.cj.jdbc.Driver

spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

 

posted @ 2020-04-22 10:01  程序生(Codey)  阅读(230)  评论(0编辑  收藏  举报