alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.99k stars 8.59k forks source link

数据库密码加密时,长时间未访问数据库,报errorCode 1045, state 28000 #2268

Open lihongchun opened 6 years ago

lihongchun commented 6 years ago

异常信息如下(隐藏了db信息):

create connection SQLException, url: jdbc:mysql://**/, errorCode 1045, state 28000 java.sql.SQLException: Access denied for user '**'@'' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2194) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2225) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2024) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:779) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47) at sun.reflect.GeneratedConstructorAccessor84.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330) at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:149) at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:786) at com.alibaba.druid.filter.FilterEventAdapter.connection_connect(FilterEventAdapter.java:38) at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:786) at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:786) at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218) at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1470) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1533) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2333)

7040210 commented 6 years ago

我也遇到这样的问题,环境是SpringBoot,在项目启动的时候是没问题的,打断点能看到运行到MySQL的连接是密码是解密过的,但是当连接断开后,目前Druid设置的是7小时,重新获取连接的时候并没有执行数据解密操作,不知道是我设置的问题还是怎么回事,数据库拿到的就是密文,所有就无法连接数据库了。

wenshao commented 6 years ago

比较奇怪哦

lihongchun commented 6 years ago

spring boot 项目,启动时(org.springframework.beans.factory.InitializingBean#afterPropertiesSet中)查询数据库数据,会存在该问题,启动时不加载数据库数据时无该问题

singAllSong commented 6 years ago

我擦,终于找到了一个志同道合的,你这问题跟我那问题一样

2302

ChenBravery commented 6 years ago

我也有类似问题: https://github.com/alibaba/druid/issues/2312

hackeryutu commented 6 years ago

我也有类似问题。

nibaohua commented 6 years ago

那现在又解决方案吗? 之前我也没有遇到,最近有一台机器也一直会出现这个问题

chenkline commented 6 years ago

最好的方式是不要使用druid的加密配置功能,使用spring-cloud-config本身的加密配置功能,从而绕过这个bug

Anyzm commented 4 years ago

我也碰到了,怎么解决?为啥没有大佬出来解答啊?

Anyzm commented 4 years ago

我也碰到了,怎么解决?为啥没有大佬出来解答啊?

我是springboot+apollo

pigbayspy commented 2 months ago

同问这个问题,这个问题在 1.2.8 中存在

Anyzm commented 2 months ago

感谢您的来件,邮件已收到。