IDEA连接MySQL错误

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

IDEA连接MySQL错误

MySQL8.0配置成功后,在idea中进行连接,发现报错信息如下:

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

这实际上是mysql的url时区的陷阱:在使用mysql的6.0.x以上的jar的时候,需要在代码url的链接里面指定serverTimezone。否则就会出现异常

***注意:mysql5.6版本出现这个问题时,在my.ini配置文档中添加:

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

即可解决!***,但是MySQL8.0实测无效!

MySQL8.0解决方法:

方法一(不推荐)

1、命令行登录MySQL

mysql -u root -p

2、查看并修改MySQL时区

show variables like ‘%time_zone%‘

SYSTEM,时间不对需要修改,MySQL默认SYSTEM是美国时间,比我国要晚了8个小时

set global time_zone = ‘+8:00‘;

修改后,要退出MySQL,重新登录。查看时区,修改成功,然后我们重新用idea连接MySQL,测试连接发现问题解决。

问题:当MySQL服务重启的时候,会发现我们修改的时间被重置成立SYSTEM,问题依然存在。

方法二、

在idea中进行连接,database的Event log(idea右下角)

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.

所以有两个方法:

1、修改IDEA的database的配置

2、修改URL

问题补充:

MySQL8.0的连接池是com.mysql.cj.jdbc.Driver,之前5.7版本是com.mysql.jdbc.Driver

原文地址:https://www.cnblogs.com/yinminbo/p/11829117.html

时间: 2024-08-02 21:48:17

IDEA连接MySQL错误的相关文章

解决远程连接mysql错误1130

Mysql远程连接Mysql服务器的数据库,错误代码是1130,ERROR 1130: Host xxx.xxx.xxx.xxx  is not allowed to connect to this MySQL server  猜想是无法给远程连接的用户权限问题. 这样子操作mysql库,即可解决.  在本机登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称

解决远程连接mysql错误1130(转载)

解决远程连接mysql错误1130 远程连接Mysql服务器的数据库,错误代码是1130,ERROR 1130: Host xxx.xxx.xxx.xxx  is not allowed to connect to this MySQL server  猜想是无法给远程连接的用户权限问题. 这样子操作mysql库,即可解决. 在本机登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"local

spring boot 连接mysql 错误The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one

1.spring boot 整合mybatis 连接mysql时错误 The server time zone value '?D1ú±ê×?ê±??' is unrecognized or represents more than one 2.解决: jdbc:mysql://localhost:3306/new_schema?useSSL=false&serverTimezone=GMT%2B8 在地址后面加上 &serverTimezone=GMT%2B8%2B是+号的意思,这个意思

解决MAC下PHP连接MYSQL错误Warning: mysql_connect(): No such file or directory in conn.php

今天在mac上用php去连接mysql数据库,出现了 mac PHP Warning:  mysql_connect(): [2002] No such file... 详细例如以下所看到的: DirkMacBook:vote Dirk$ phpunit MyTest.php  Warning: mysql_connect(): No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/myvote/vote/conn.

EntityFramwork6连接MySql错误

使用EF6连接MySql产生Exception: ProHub.ssdl(2,2) : 错误 0152: 未找到具有固定名称“MySql.Data.MySqlClient”的 ADO.NET 提供程序的实体框架提供程序.请确保在应用程序配置文件的“entityFramework”节中注册了该提供程序.有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=260882. 英文: No Entity Framework provider found fo

解决远程连接mysql错误1130代码的方法

今天在用远程连接Mysql服务器的数据库,不管怎么弄都是连接不到,错误代码是1130,ERROR 1130: Host192.168.2.159 is not allowed to connect to this MySQL server 猜想是无法给远程连接的用户权限问题.结果这样子操作mysql库,即可解决.在本机登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost&qu

连接MySQL错误“plugin caching_sha2_password could not be loaded”的解决办法

MySQL新版默认使用caching_sha2_password作为身份验证插件,而旧版是使用mysql_native_password.当连接MySQL时报错“plugin caching_sha2_password could not be loaded”时,可换回旧版插件. mysql -hlocalhost -uroot -p123456 //进入数据库use mysql;ALTER USER [email protected] IDENTIFIED WITH mysql_native_

php 连接mysql 错误排查一例

php后台接不上mysql数据库,查看phpinfo,mysql驱动正常. 查看日志 发现配置正确,连接被拒,猜想可能是用户权限的问题 进入数据库查看用户和权限 [[email protected] wezchina]# mysql -h 192.168.2.100 -P 3306 -uSbsBL6tnULzkI21 -p Enter password:  ERROR 1045 (28000): Access denied for user 'user'@'MyCloudServer' (usi

Kettle连接MySQL错误:OPTION SQL_SELECT_LIMIT=DEFAULT

由于升级了MySQL到5.6,运行ETL报错: OPTION SQL_SELECT_LIMIT=DEFAULT 上网查询原来是MySQL的驱动版本不一致,之前的驱动不支持这样的写法,于是上网下载对应的驱动,解决! http://dev.mysql.com/doc/relnotes/connector-j/en/news-5-1.html mysql-connector-java-5.1.33-bin.rar