IDEA MySQL connection error

Reference: https: //www.dazhuanlan.com/2019/08/25/5d616a1fe73ac/

IDEA MySQL connection error

After MySQL8.0 configured successfully, the connection is the idea, given the information found as follows:

Connection to @localhost failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.

 This is actually a trap when the area mysql url: use mysql or more 6.0.x jar when you need to specify serverTimezone the url link code inside. Otherwise there will be an exception

*** NOTE: mysql5.6 version of this problem when, in my.ini configuration document added:

default-time-zone = '+8:00'

Can be solved! ***, but MySQL8.0 found invalid!

MySQL8.0 Solution:

A method (not recommended)

1, MySQL command line login

mysql -u root -p

2, view and modify MySQL time zone

show variables like '%time_zone%'

 

SYSTEM, time does not need to be modified, MySQL is the default SYSTEM US time, our country is later than the 8 hours

set global time_zone = '+8:00';

After modification, to withdraw from MySQL, log in again. When viewing zone, modify successfully, and then we re-connect with the idea MySQL, test the connection to find and solve.

Question: When restarting the MySQL service, we will find modified time is reset establishment SYSTEM, the problem still exists.

Method Two,

Connection, database idea in the Event log (idea bottom right)

Caused by: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

So there are two ways:

1, a configuration database to modify the IDEA

2, modify the URL

Questions added:

MySQL8.0 connection pool is com.mysql.cj.jdbc.Driverbefore version 5.7com.mysql.jdbc.Driver

 

 

 

Guess you like

Origin www.cnblogs.com/yinminbo/p/11829117.html