php 为什么 MySQL 连接因许多连接错误而被阻止?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20014746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why MySQL connection is blocked of many connection errors?
提问by Nick
As you can see I have a problem on a database connection. It gives me this error:
如您所见,我在数据库连接上遇到了问题。它给了我这个错误:
...is blocked because of many connection errors
...由于许多连接错误而被阻止
I searched some answers but I couldn't solve my problem.
我搜索了一些答案,但我无法解决我的问题。
I don't know if I gave all the information that you need, so if you need something else, just tell me. I have a database connection from different computers and I had a user created to access the database but it had %in the hosts row, so I wanted to change it with an IP address for security issues and it gave me this error so now I'm stuck.
我不知道我是否提供了您需要的所有信息,因此如果您需要其他信息,请告诉我。我有一个来自不同计算机的数据库连接,我创建了一个用户来访问数据库,但它%在主机行中,所以我想用 IP 地址更改它以解决安全问题,它给了我这个错误,所以现在我卡住。
回答by Jason Heo
MySQL blocks clients which error made while connecting to protect MySQL from malformed client.
MySQL 会阻止在连接时出错的客户端,以保护 MySQL 免受格式错误的客户端的影响。
So first, you need to find what sort of error is....
所以首先,你需要找出什么样的错误是......
You might check MySQL error log in data directory. (typically hostname.err)
您可以检查数据目录中的 MySQL 错误日志。(通常是hostname.err)
Or, you can increase max_connect_errors(what is current value?) maximum value depends on architecture. on 32 bit, 4294967295. 18446744073709547520 for 64 bit. (Manual)
或者,您可以增加max_connect_errors(什么是当前值?)最大值取决于架构。32 位为 4294967295。64 位为 18446744073709547520。(手册)
mysql> SET GLOBAL max_connect_errors = 100000000;
But this is not real solution if error is frequently occurred.
但是如果经常发生错误,这不是真正的解决方案。
FLUSH HOSTScan help you to eliminate blocked host right now.
FLUSH HOSTS可以帮助您立即消除被阻止的主机。
mysql> FLUSH HOSTS;
If want to run from outside mysql console then use mysqladmin command:
如果想从外部 mysql 控制台运行,则使用 mysqladmin 命令:
# mysqladmin flush-hosts
回答by Syeful Islam
First flush hosts local MySQL using following command:
首先使用以下命令刷新主机本地 MySQL:
mysqladmin -u [username] -p flush-hosts
**** [MySQL password]
or
或者
mysqladmin flush-hosts -u [username] -p
**** [MySQL password]
network MySQL server:
网络 MySQL 服务器:
mysqladmin -h <ENDPOINT URL> -P <PORT> -u <USER> -p flush-hosts
mysqladmin -h [END POINT URL] -P 3306 -u [DB USER] -p flush-hosts
In additional suggestion you can permanently solve blocked of many connections error problem by editing my.ini file[Mysql configuration file]
另外建议你可以通过编辑my.ini文件[Mysql配置文件]永久解决blocked of many connections错误问题
change variables max_connections = 10000;
更改变量 max_connections = 10000;
or
或者
login into MySQL using command line -
使用命令行登录 MySQL -
mysql -u [username] -p
**** [MySQL password]
put the below command into MySQL window
将以下命令放入 MySQL 窗口
SET GLOBAL max_connect_errors=10000;
set global max_connections = 200;
check veritable using command-
使用命令检查名副其实
show variables like "max_connections";
show variables like "max_connect_errors";

