# MySQL 8: Could not create connection to database server

**URL:** <https://discuss.elastic.co/t/mysql-8-could-not-create-connection-to-database-server/280064>\
**Category:** Logstash\
**Created:** [July 30, 2021, 9:45am UTC](https://discuss.elastic.co/t/mysql-8-could-not-create-connection-to-database-server/280064 "2021-07-30T09:45:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Morgan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_morgan/32/77578_2.png) [@Justin\_Morgan](https://discuss.elastic.co/u/Justin_Morgan)\
**Post date:** [July 30, 2021, 9:45am UTC](https://discuss.elastic.co/t/mysql-8-could-not-create-connection-to-database-server/280064/1 "2021-07-30T09:45:02Z")

</div>

After upgrading to MySQL 8 I get the following error from my logstash pod:

```auto
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.
[2021-07-30T09:31:38,885][ERROR][logstash.inputs.jdbc][main][f5be98a71736413fe373dedbd282a1ee25b169118a57eab4e43cc9337c337a2c] Unable to connect to database. Trying again {:error_message=>"Java::JavaSql::SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up."}

```

I upgraded to MySQL connector version 8.0.23 to match my MySQL version 8.0.23. Using logstash 7.8.1.

Relevant part of the config:

```auto
jdbc_driver_library => "/opt/bitnami/logstash/logstash-core/lib/jars/mysql-connector-java.jar"
    jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://mydb.database:3306/dbname?zeroDateTimeBehavior=convertToNull&useCursorFetch=true&autoReconnect=true&sessionVariables=group_concat_max_len=150000"

```

I tried it with jdbc\_driver\_library commented out too.

I'm not sure why I get the warning about the Java class name being wrong when jdbc\_driver\_class is already set to com.mysql.cj.jdbc.Driver

---

<div class="post-metadata">

**Author:** ![Justin\_Morgan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_morgan/32/77578_2.png) [@Justin\_Morgan](https://discuss.elastic.co/u/Justin_Morgan)\
**Post date:** [July 30, 2021, 11:57am UTC](https://discuss.elastic.co/t/mysql-8-could-not-create-connection-to-database-server/280064/2 "2021-07-30T11:57:29Z")

</div>

I got around this by bypassing the proxy sql server.

I'm now getting a different error:

`[2021-07-30T11:56:30,283][WARN][logstash.inputs.jdbc][main][b59e523212418c01261b23483dd355d782cac58686142d9665b4d07fee6ae3d7] Exception when executing JDBC query {:exception=>"Java::JavaSql::SQLException: Incorrect DATE value: ''"}`

which seems odd since I have the

```auto
zeroDateTimeBehavior=convertToNull

```

setting ??

Edit: that was just a problem in the query I was using

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 27, 2021, 11:57am UTC](https://discuss.elastic.co/t/mysql-8-could-not-create-connection-to-database-server/280064/3 "2021-08-27T11:57:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
