MySQL: "Could not create connection to database server" when creating database


I switch from HSQL to MySQL in a project and everytime I tried to create the database I get the error
MySQLNonTransientConnectionException: Could not create connection to database server (see attachment).

When I test the connection in the project properties dialog, everythink works fine:


I hope someone can help me.


log.txt (1.0 KB)

Could you please share idea.log with us?. You could find it here:

Also, could you please provide the version of JDBC connector that you use?

Hi Natalia,

I think I found the problem. I use MySQL 8 with JDBC-Driver 8.0.13. But in your automatically created build.gradle you use version 5.1.46:

def mysql = ‘mysql:mysql-connector-java:5.1.46’

After changing it to 8.0.13

def mysql = ‘mysql:mysql-connector-java:8.0.13’

everything works fine.


We strongly recommend using the 5.1.46 version of the driver, here is the link to download. Using version 8.0.13 may cause some problems.

I have encounter the same problem, i inspect the idea.log and found the problem.
The workround is append a parameter to url : serverTimezone=UTC

1 Like