alibaba / druid

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

使用SpringCloud刷新配置报连不上mysql,账户密码错误,数据库密码做了加密的 #3312

Closed ghost closed 5 years ago

ghost commented 5 years ago

SpringBoot版本:2.0.3 SpringCloud版本:Finchley.SR2 背景:配置数据库账户密码的ymal文件放在Git上,通过ConfigServer读取配置文件。数据库密码使用druid(1.1.9)进行加密 重现步骤:服务成功启动且能正常访问的情况下,不对配置文件做任何改动,当然也不改数据库密码,然后使用POST请求 ip:port/actuator/bus-refresh ,访问接口时必现。 报错如下:

2019-06-28 05:34:31.161 payment ERROR com.alibaba.druid.pool.DruidDataSource Line:2469 - create connection SQLException, url: jdbc:mysql://xx.xxx.xx.xx:3306/xxxx?characterEncoding=utf-8, errorCode 1045, state 28000 java.sql.SQLException: Access denied for user 'root'@'xx.xx.xx.xx' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1714) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:776) at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47) at sun.reflect.GeneratedConstructorAccessor122.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:386) 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.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:1515) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1578) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2466)

ghost commented 5 years ago

找出问题了,自己的锅,yml文件中配置了 filter: config: enabled: true 却没有配置filters: config