您的位置:首页 > 数据库 > MySQL

远程连接mysql容易遇到的2个问题

2015-12-08 13:19 666 查看

1."com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago."

解决方案:

vi /etc/mysql/my.cnf
#bind-address            = 127.0.0.1 // 注释掉
service mysql restart

参考:stackoverflow

2."Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server"

解决方案:

CREATE USER 'admin'@'%' IDENTIFIED BY 'admin';
GRANT ALL PRIVILEGES ON \*.\* TO 'admin'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH privileges

参考:stackoverflow
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: