MySQL远程连接报错2003-cant connection to mysql server on ‘IP’(10061 unknown error)的解决

**首先去看有没有关闭防火墙!!!**

停止firewall服务 systemctl stop firewalld.service
禁止firewall开机启动 systemctl disable firewalld.ser

***下面为https://blog.csdn.net/alwaysbefine/article/details/116332945 晚风_end所写*** ![在这里插入图片描述](https://img-blog.csdnimg.cn/7c64b88606e949bb9116e48914fce968.png)

首先,得说明一下,本文讨论的是远程连接MySQL数据库。

其次,该报错的意思是未知错误导致无法远程连接MySQL。

该报错的解决也很简单,总共从四个方面着手解决即可。

一,检查MySQL服务是否正常启动

如果mysql的server服务并没有启动,那么,你任何的客户端都是别想使用服务,自然谈不到连接了,不管是远程还是本地连接。

二,如果服务是正常的,那么需要检查配置文件。

查看配置文件内是否有bind-address选项,该选项的值如果为127.0.0.1,那么,将该值更改为本机IP或者0.0.0.0或者注释该行。

例如,我这个mysql的配置文件内容如下,其中的bind-address值是127.0.0.1,那么,远程连接的时候将会报错。

 root@3b5e59d2d7e0:/# cat -n /etc/mysql/my.cnf1 # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2   #3  # This program is free software; you can redistribute it and/or modify4 # it under the terms of the GNU General Public License as published by5 # the Free Software Foundation; version 2 of the License.6  #7  # This program is distributed in the hope that it will be useful,8  # but WITHOUT ANY WARRANTY; without even the implied warranty of9   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the10   # GNU General Public License for more details.11    #12 # You should have received a copy of the GNU General Public License13   # along with this program; if not, write to the Free Software14 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA15   16  #17 # The MySQL  Server configuration file.18   #19 # For explanations see20    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html21  22  [mysqld]23  pid-file        = /var/run/mysqld/mysqld.pid24 socket          = /var/run/mysqld/mysqld.sock25    datadir         = /var/lib/mysql26 secure-file-priv= NULL27   28  bind-address=127.0.0.129   # Custom config should go here30    !includedir /etc/mysql/conf.d/

将28行注释或者更改为0.0.0.0, 或者注释掉这一行,重启MySQL服务,即可远程连接了。

三,检查配置文件,server所开放的端口

例如,本文的第一张图,很明显,我是写了一个错误的端口号3301,实际上,我使用的是默认端口3306

密码错误是报这个错哦:

四,MySQL数据库服务并没有给root或者别的用户开放远程连接的权限。

如果登陆MySQL服务器后,执行 select user,host from user;查询的结果如下的话,那么会报上图的错,不是2003哦:

mysql> select user,host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
4 rows in set (0.01 sec)

开启远程连接:

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

或者这样开启:

mysql> grant all privileges on *.* to root@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

总结:
2003错误的解决,首先,是看MySQL的服务是否正常,ps命令查看进程等等方式确认服务正常即可,其次,是看配置文件内的绑定IP选项是否绑定了localhost或者127.0.0.1回环地址,再次,查看服务所启动的端口是否和远程连接时使用的端口一致。

2003-Can‘t connect to MySQL server on ‘192.168.232.128(10060 “Unknown error“)相关推荐

  1. 主机连接虚拟机MySQL报错:Can't connect to Mysql server on '192.168.33.10' (10061 Unknown error)

    之前写过一篇文章,是关于主机连接虚拟机时报无法连接的文章(主机连接虚拟机MySQL报错:Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this ...

  2. 远程连接mysql(linux)2003 - Can‘t connect to Mysql server on ‘xxx.xxx.xxx.xxx‘(10061“Unknown error“)

    问题: 有一段时间没有连接一台服务器的数据库了,用navicat连接时发现错误如下: 不知道什么原因服务器上的mysql自动关闭了. 登录服务器 进入 var/lib/mysql/目录下重启mysql ...

  3. mysqldump: Got error: 2003: Can't connect to MySQL server on '127.0.0.1' (10060)

    今天在用批处理进行MySQL自动备份的过程中遇到一个问题,错误提示:mysqldump: Got error: 2003: Can't connect to mysql server on '127. ...

  4. 113 错误 mysql_ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.105' (113)

    [root@mysql ~]# mysql -uroot -h192.168.56.105 -p Enter password: ERROR 2003 (HY000): Can't connect t ...

  5. 113 错误 mysql_mysql添加,授权,删除用户以及连接数据库Can't connect to MySQL server on '192.168.31.106' (113)错误排查...

    centos7下面操作mysql添加,授权,删除用户 添加用户 以root用户登录数据库,运行以下命令: create user test identified by '123456789'; 上面创 ...

  6. ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解决方法

    谷歌了一下之后,原来是在mysql的my.cnf中有下面一段代码: # Instead of skip-networking the default is now to listen only on ...

  7. Cant connect to MySQL server on 192.168.164.130

    前提 192.168.164.130能ping通 192.168.164.130的3306端口已启动 mysql的配置文件没有通过bind-address绑定非对端主机的IP 测试 telnet 19 ...

  8. ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘192.168.1.165‘ (113)

    登录mycat服务器,关闭防火墙即可 # centos7 systemctl stop firewalld# centos6 service iptables stop

  9. MySQL远程连接ERROR 2003 (HY000) Cant connect to MySQL server on (10060)

    MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX' (10060)的问题 D:\Users\xiaomaimiao& ...

最新文章

  1. SCCM2016 集成WSUS提供补丁服务(一)
  2. ZF2系列 – Zend Framework 2 MVC實作 (Part 3)
  3. 微软项目技术结构思路 ExtJs/JQuery + Asp.net MVC + Wcf service + Entity Framework
  4. 计算机安全可靠替代工程,基于安全可靠软硬件的党政军OA系统的整系统优化方法与研究-计算机技术专业论文.docx...
  5. mysql 默认时间字段 1067,mysql替datetime类型字段设置默认值default
  6. 【docker】kubernetes集群一键部署包
  7. python中linspace函数_python np.linspace
  8. 欢迎关注个人微信公众账号~
  9. 2022年电脑杀毒软件PK
  10. python爬取英雄联盟所有皮肤价格表_python 爬取英雄联盟皮肤并下载的示例
  11. OpenCV批量处理图片
  12. 哪些浏览器支持html5?
  13. 如何在office2016(word2016)中安装mathtype6.9及相关问题解决方案
  14. 计算机网络——(6)网络互联技术与设备
  15. 语音信号去混响原理与技术
  16. Python基础第一课
  17. 重磅 | 推荐一款技术人必备的写作神器 (支持多平台自动同步)
  18. 互联网广告作弊的危害,以及如何反作弊
  19. 微信小程序view下的字体居中显示
  20. HDU 2201 熊猫阿波的故事

热门文章

  1. 有关USB延长线供电不足的解决
  2. Linux下查询tomcat进程命令
  3. IDC发布:云信达引领CDM赛道,帮助企业盘活副本暗数据
  4. Windows API 教程(九) 网络编程
  5. 公众号 自动生成海报 python_美翻你的朋友圈,Python生成蒙太奇马赛克图片
  6. 计算机辅助药物设计 fda,计算机辅助药物设计中的分子动力学模拟.pdf
  7. Word初学者编辑文字时注意改写和插入两种状态
  8. python梦幻西游鼠标偏移_梦幻西游鼠标漂移,求修改,不知道错误在哪
  9. 图的最短路径之(迪杰斯特拉算法)python实现
  10. 20年吉林省综合测评