ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.157' (111)
来源:互联网 发布:php程序员培训机构 编辑:程序博客网 时间:2024/06/06 04:35
1.MySQL本地可以登录,但是不能远程登录。
[root@nb0 ~]# mysql -h192.168.1.157 -uroot -pEnter 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.157PING 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 ms64 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 1000msrtt min/avg/max/mdev = 0.242/0.252/0.262/0.010 ms
3. MySQL的端口是默认的
[root@my ~]# netstat -nlp|grep 3306tcp 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# ls50-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 -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MySQL connection id is 10Server 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)]>
1 0
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.157' (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.114' (111)
- 解决"ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.247.128' (111)"
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.10.210' (111) 解决方法
- ERROR 2003 (HY000): Can’t connect to MySQL server on ’192.168.119.105′ (10061)
- 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)
- centos6下解决"ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.2.200' (113)"
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)
- ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)
- 解决ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)
- 解决ERROR 2003 (HY000): Can't connect to MySQL server on "host" (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 '10.16.115.101' (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xx.xxx' (111)
- ERROR 2003 (HY000): Can't connect to MySQL server on '223.3.46.114' (111)
- 临界区和互斥器的区别
- Eddy的难题
- 关于Session(javax.servlet.HttpSession)持久化----为什么实体类需要实现序列化接口
- 随记6——Android透明度值
- [资源]第三方免费接口
- ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.157' (111)
- 设计模式学习笔记——原型(Prototype)框架
- SQL查询索引失效的情况
- ajax请求基本方式
- 使用ViewPager动画来做出不一样的引导页
- 质因数分解(改良版2)
- 有趣图表值——chart wheel
- 【eclipse开发工具】从svn检出项目不是web项目
- HttpClient简单使用之GET请求