简体   繁体   English

mysql连接到远程数据库

[英]mysql connect to remote DB

I have a cluster witht a database saved on the master. 我有一个群集,其中数据库保存在主数据库上。 I would like to connect from the workers to the db. 我想从工人连接到数据库。

Here what I did on the master: 这是我对主人所做的:

bomble@master:~$ mysql -u root
mysql>  GRANT ALL ON ChemAlive_DB.* TO root@worker1 ;

And on the worker1: 在worker1上:

bomble@worker1:~$mysql -u root  -h xx.xx.xxx.xxx

I also tried: 我也尝试过:

bomble@worker1:~$ mysql -u bomble -h xx.xx.xxx.xxx bomble @ worker1:〜$ mysql -u bomble -h xx.xx.xxx.xxx

In both case I get: 在两种情况下,我都会得到:

ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xxx.xxx' (110) 错误2003(HY000):无法连接到“ xx.xx.xxx.xxx”上的MySQL服务器(110)

Ping is working but not telnet: Ping正在工作,但无法使用telnet:

bomble@worker1:~$ ping xx.xx.xxx.xxx
PING xx.xx.xxx.xxx (xx.xx.xxx.xxx) 56(84) bytes of data.
64 bytes from 10.0.0.254: icmp_seq=1 ttl=64 time=1.04 ms
64 bytes from 10.0.0.254: icmp_seq=2 ttl=64 time=0.939 ms
64 bytes from 10.0.0.254: icmp_seq=3 ttl=64 time=0.887 ms

--- xx.xx.xxx.xxx ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.887/0.956/1.044/0.074 ms
bomble@worker1:~$ telnet xx.xx.xxx.xxx
Trying xx.xx.xxx.xxx...
telnet: Unable to connect to remote host: Connection refused

How should I proceed? 我应该如何进行?

Check your config, maybe bind-address = 127.0.0.1 is not commented If you use Debian or Ubuntu run the command vim /etc/mysql/my.cnf and comment bind-address = 127.0.0.1 using the # symbol, after restart your mysql server once. 检查您的配置,也许未评论bind-address = 127.0.0.1如果使用Debian或Ubuntu,请运行命令vim /etc/mysql/my.cnf并使用#符号注释bind-address = 127.0.0.1,重新启动后, mysql服务器一次。 If is not helped, check skip-external-locking (for remote connected must be not commented) 如果没有帮助,请检查“ skip-external-locking”(跳过外部锁定)(对于远程连接,请勿添加注释)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM