- 第一个问题:连接超时
提示:The last packet sent successfully to the server was 0 milliseconds ago.
解决:在my.cnf文件末增加连接时长并重启
interactive_timeou=28800
wait_timeout=28800
systemctl restart mysqld.service
说明: interactive_timeout也是必须要修改的参数,这样一起改才能生效,其中wait_timeout就是负责超时控制的变量。
- 第二个问题:开启远程连接
提示:message from server: “Host ‘远程IP’ is not allowed to connect to this MySQL server”
解决:在mysql数据库中的user中增加一个字段
#查看现在使用的数据库
select database();
#使用mysql数据库
use mysql;
#增加字段
mysql -u user_1 -p -h 远程服务器IP;
#更新数据
flush privileges;
- 第三个问题:主键
提示:Public Key Retrieval is not allowed
出现问题原因:重启了mysql服务,flush privileges;
解决:我用的是在jar配置文件中的连接数据库加入
allowPublicKeyRetrieval=true