ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.157' (111)
2017-04-13 09:34
381 查看
1.MySQL本地可以登录,但是不能远程登录。
[root@nb0 ~]# mysql -h192.168.1.157 -uroot -p Enter password: ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.157' (111)
2. MySQL服务器是可以ping通的
[root@nb0 ~]# ping 192.168.1.157 PING 192.168.1.157 (192.168.1.157) 56(84) bytes of data. 64 bytes from 192.168.1.157: icmp_seq=1 ttl=64 time=0.242 ms 64 bytes from 192.168.1.157: icmp_seq=2 ttl=64 time=0.262 ms ^C --- 192.168.1.157 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.242/0.252/0.262/0.010 ms
3. MySQL的端口是默认的
[root@my ~]# netstat -nlp|grep 3306 tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 24061/mysqld
4.解决办法
将mysql配置文件中的bind-address = 127.0.0.1注释掉
[root@my ~]# vi /etc/mysql/mysql.conf.d/mysqld.cnf # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1
如果安装的是Mariadb10,对应目录文件会发生一些改变
[root@my ~]# cd /etc/mysql/mariadb.conf.d [root@my ~]/etc/mysql/mariadb.conf.d# ls 50-client.cnf 50-mysql-clients.cnf 50-mysqld_safe.cnf 50-server.cnf
然后编辑50-server.cnf文件,同样是注释掉
bind-address
vi 50-server.cnf
重启MySQL
[root@my ~]:~# sudo service mysql restart
重新远程连接
[root@nb0 ~]# mysql -h192.168.1.157 -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.7.11-0kord6 (Ubuntu) Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]>
相关文章推荐
- Ubuntu ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
- 解决ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)
- (笔记)远程连接MySQL出现ERROR 2003 (HY000): Can't connect to MySQL server on ip (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on '172.16.160.182' (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on '10.16.115.101' (111)
- MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'(111) 的问题
- windows安装mysql的坑:ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060)
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.123' (10061)
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.105' (113)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061) 解决办法
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- ERROR 2003 (HY000):CAN’T CONNECT TO MYSQL SERVER ON ‘LOCALHOST’ (10061)
- 【解决】ERROR 2003 (HY000): Can't connect to MySQL server on "host" (113)
- ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)
- MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题
- 解决 error 2003 (hy000): can't connect to mysql server on 'localhost' (10061)
- mysql 解决 ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)