Data source rejected establishment of connection, message from server: “Too many connections

运行项目

报错信息如下:

=============================================================

2023-06-30 16:57:19.660 INFO  [main] c.a.d.s.b.a.DruidDataSourceAutoConfigure - Init DruidDataSource
2023-06-30 16:57:20.497 ERROR [main] c.alibaba.druid.pool.DruidDataSource - init datasource error, url: jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8&useSSL=false
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection,  message from server: "Too many connections"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    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:409)

=============================================================

可能是数据源的配置数值不合理:

比如这个,线上需要使用大数值的配置,但是这个配置在本地电脑跑不起来,可以本地dev环境配置将数值降低,注意  线上配置最好使用原数值不要动!!!!

Data source rejected establishment of connection, message from server: “Too many connections_第1张图片

 本地dev环境改为:

spring:
  profiles:
    active: dev
  application:
    name: user-server
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    druid:
      initialSize: 5
      minIdle: 5
      maxActive: 20
      maxWait: 60000

Data source rejected establishment of connection, message from server: “Too many connections_第2张图片

 

 

你可能感兴趣的:(java,druid,springboot)