mysql链接错误:Lost connection to MySQL server at 'reading authorization packet', system error: 0

在远程连接mysql的时候,连接不上,出现如下报错:
Lost connection to MySQL server at ‘reading authorization packet‘, system error: 0
原因分析:
mysql开启了DNS的反向解析功能,这样mysql对连接的客户端会进行DNS主机名查找。
mysql处理客户端解析过程:
1)当mysql的client连过来的时候,服务器会主动去查client的域名。
2)首先查找 /etc/hosts 文件,搜索域名和IP的对应关系。
3)如果hosts文件没有,则查找DNS设置,进行DNS反向解析,直到timeout连接失败。
mysql的DNS反向解析:
1)mysql接收到连接请求后,获得的是客户端的ip,为了更好的匹配mysql.user里的权限记录(某些是用hostname定义的)。
2)如果mysql服务器设置了dns服务器,并且客户端ip在dns上并没有相应的hostname,那么这个过程很慢,导致连接等待。

解决方案:
1)把client的ip写在mysql服务器的/etc/hosts文件里,随便给个名字做主机映射即可。
2)在my.cnf配置文件中的[mysqld]区域添加skip-name-resolve,即跳过mysql连接的DNS反向解析功能,这样能很好地提高mysql性能。在这种情况下,就只能使用MySQL授权表中的IP来连接mysql服务了。
对于第一种方法显然比较笨,也不实用!强烈推荐第二种方法,添加skip-name-resolve选项可以禁用dns解析,这样的话,就不能在mysql的授权表中使用主机名了,只能使用IP。
--------------------------------------------------------------------------------------------------------------
另外:
如果在my.cnf文件中配置了bind-address地址绑定的地址(说明别的机器远程只能通过这个绑定的本机地址来连接mysql),可以将其注释掉。
例如:
bind-address = 127.0.0.1       //说明只能在本机连接mysql,并且通过-h 127.0.0.1或localhost,在远程是无法连接这个mysql的!
--------------------------------------------------------------------------------------------------------------

my.cnf配置的几个参数:
skip-name-resolve         跳过DNS反向解析过程.(这样就不能使用主机名连接mysql了,只能使用ip连接)
skip-grant-tables           跳过授权表(当mysql登陆密码忘记时的解决办法)
skip-networking            跳过TCP/IP连接
skip-host-cache            禁用主机名缓存;要想清除主机名缓存,执行FLUSH HOSTS语句或执行mysqladmin flush-hosts命令

mysql链接错误:Lost connection to MySQL server at 'reading authorization packet', system error: 0

原文地址:https://www.cnblogs.com/aten/p/9726550.html

时间: 2024-08-28 18:31:15

mysql链接错误:Lost connection to MySQL server at 'reading authorization packet', system error: 0的相关文章

Lost connection to MySQL server at 'reading authorization packet' 处理解决办法

Mysql Version : 5.1.73 Os Version : Centos 5.9 问题叙述: 今天一个php程序从客户端连接Mysql被监测到在偶尔的连接过程中报错,信息如下: Lost connection to MySQL server at 'reading authorization packet',看到这个错误提示,第一想到是客户端连接不上,服务端本地是否能连接.经验证,服务端本地是可以连接的,这就松了口气,一方面有很多任务是跑在Mysql服务端的,如果本地无法连接,会造成

mysql登陆时出现ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

有4到5天没开mysql,这天晚上打=打开phpstudy,想进去mysql练习练习,结果丢给我这个 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 错误2013 (HY000):读取初始通信包时MySQL服务器连接丢失,系统错误0 windows进cmd命令行,输入server.msc,然后找到mysql的服务,重启一下就

虚拟机中MySQL连接问题:Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql

环境:在VirtualBox中安装了Ubuntu虚拟机,网络使用了NAT模式,开启了端口转发. 局域网内其他计算机访问虚拟机中的MySQL Server出现两个问题: Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql 1.解决Lost connection to MySQL server

Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 mysql远程连接问题

在用Navicat for MySQL远程连接mysql的时候,出现了 Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 好恶心,服务器重启了一次,就一上午都是在处理mysql的各种问题. 第一步:找到:my.cnf文件 其实我也不知道在哪里,用指令帮我们找吧. find / -name my.cnf 找到了后. 第二步:vi my.cnf vi my.cnf 在m

Lost connection to MySQL server at 'reading initial communication packet',system error:0

如果网上各种文档告诉你去配置/etc/my.cnf,你没找到的话,不防试试我这个,文件的位置在: 去里面找找看 注释掉bind-address 然后重置下密码: use mysql update user set authentication_string=password('wxhcj1314520'),plugin='mysql_native_password' where user='root'; 然后刷新一下: flush privileges; Lost connection to M

Mysql Lost connection to MySQL server at ‘reading initial communication packet', system error: 0

在用Navicat for MySQL远程连接mysql的时候,出现了 Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 修改my.cnf文件(windows为my.ini) 一般在mysql的安装目录,/etc/mycnf. 在my.cnf配置文件中的[mysqld]区域添加skip-name-resolve,看网友说的是跳过mysql连接的DNS反向解析功能,这

使用cmd命令登录mysql数据库时报2013-Lost connection to MYSQL server at 'waiting for initial communication packet',system error:0

[错误内容]:SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', system error: 0 [错产生经过]:链接MySQL时出现. [解决办法]:打开my.ini,找到[mysqld]项,在其后加入一句:skip-name-resolve,保存,重启mysql服务即可~ 以上就是解决MySQL Error (2013): Lost connectio

mysql链接错误:2003 can't connect to mysql server on 10038

出现这个错误原因是端口号不是3306. 打开D:\Program Files\MySQL\MySQL Server 5.5 \my.ini文件,当然还有其他的.ini的文件: [client] port=3306 [mysql] default-character-set=utf8 # SERVER SECTION# ----------------------------------------------------------------------## The following opt

MYSQL登录错误:mysqladmin: connect to server at 'localhost' failed

一.mysql登录错误mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: YES)'无法修改密码用 service mysqld stopmysqld_safe --skip-grant-tables &输入 mysql -uroot -p 回车进入>use mysql;> update user set