用 Oracle SQL Developer 等客户端工具远程连接 MySQL 8 会有以下错误提示:
状态: 失败 -测试失败: null, message from server: "Host 'mysqlserver.lan' is not allowed to connect to this MySQL server"
服务端登录到 MySQL 中:
use mysql;
select host from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
另,
若是客户端工具连接 MySQL 8 有提示 “状态: 失败 -测试失败: 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.” ,MySQL 服务端直接执行(重启MySQL服务后将失效,适用于不便重启服务的场景):
--查看当前MySQL设置的时区信息
show variables like '%time_zone%';
--全局时区修改为东8区
set global time_zone='+8:00';
--当前会话的时区修改为东8区
set time_zone = '+8:00';
永久修改时区配置,可修改 C:\ProgramData\MySQL\MySQL Server 8.0\my.ini 文件。打开 my.ini ,搜索 default-time-zone,如果存在就修改其值为 '+8:00' 。如果不存在,可在最后添加:
注意:若修改 my.ini 配置文件后,无法重启 MySQL 服务,可记事本打开 my.ini 文件,另存为 ASIN 编码 覆盖之。
default-time-zone='+8:00';