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


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

posted @ 2015-12-08 13:19  Andy啊  阅读(195)  评论(0编辑  收藏  举报