MySQL 5.7 has always been used before, because some changes have taken place after updating to MySQL 8.0, and some information needs to be modified in the configuration of MySQL driver connection.
In MySQL version 5.7, getting the database connection is realized by the following code
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/数据库名称","数据库账号","数据库密码");
In MySQL 8.0, you need to add a time zone. The implementation code is as follows
connection = DriverManager.getConnection(” jdbc:mysql :// localhost:3306/ Database name true & amp; characterEncoding=utf-8&& amp; serverTimezone=GMT%2B8& Usessl = false “,” database account “,” database password “);
After completing the above modification, you can perfectly solve the connection problem of mysql8.0. The connection is successful, as shown in the figure below
Read More:
- [Solved] C# connecting to MySQL database reports an error
- [Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported
- [Solved] Mysql Build Error: [ERROR] Slave I/O for channel ‘‘: error connecting to master
- Idea connect mysql error Server returns invalid timezone. Go to’Advanced’ tab and set’serverTimezone’ property
- [Solved] Error in MySQL installation in Linux: failed dependencies xxxxx
- MySQL Build table error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser
- MySQL Error: [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
- [Solved] There is a problem with mysql8.0 without password in Navicat connection
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- IDEA maven Config MYSQL Connection Error: Could not create connection to database server.
- Cannot resolve classpath entry: e://jar/mysql-connector-java-5.1.17-bin mybatis error in reverse engineering
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- Error 1406 (22001) in MySQL: data too long for column (Fixed)
- [Solved Perfectly] MySQL ERROR 1064 (42000): You have an error in your SQL syntax;
- [Solved] MySQL Error: “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”
- [Solved] MySQL Error: Can‘t find record in ‘order_form‘
- [Solved] SQLSTATE[HY000] [2002] Connection refused to report an error when PHP connects to mysql in the docker container
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- How to Check the most CPU consuming 50 queries in MYSQL
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘