Q1: Host '...' is not allow to connect this MySQL server
问题描述:在Win10下通过Navicat连接Ubuntu 16.04 LTS系统下MySQL服务器报错,错误信息:Error 1130 - Host '...' is not allow to connect this MySQL server。
原因分析:安装mysql时执行了mysql安全脚本,只允许root在localhost登录,不允许从远程登陆。
解决措施A:修改mysql数据库的user表数据
- 在localhost(对我来说是安装了mysql的ubuntu)的机器登入mysql:
mysql -u root -p;
- 更改 mysql数据库里的 user表里的host项,从localhost改称%:
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
解决措施B:通过授权的方式处理
- 在localhost(对我来说是安装了mysql的ubuntu)的机器登入mysql:
mysql -u root -p;
- 允许用户root从IP为192.168.18.129的主机连接到mysql服务器,并使用123456作为密码:
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.18.129' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
select host, user from user;
Q2: Can't connect to MySQL server on "IP" (10061)
问题描述:上一个问题解决后,再次连接又遇到错误Can't connect to MySQL server on "IP" (10061)。
解决措施:
- 对安装在Ubuntu 16.04系统上的mysql server,打开
/etc/mysql/mysql.conf.d/mysqld.cnf文件(早期版本是打开/etc/mysql/my.cnf文件),将skip-external-locking和bind-address = 127.0.0.1这两行给注释掉。 - 重启MySQL Server:
/etc/init.d/mysql restart
- bind-address tells MySQL what interfaces to listen on
- skip-external-locking: Do not listen for TCP/IP connections at all. This option is for systems where only local requests are allowed. To allow remote connection, comment out this line.
参考资料:
报错:1130-host ... is not allowed to connect to this MySql server