This is not a fault in your MySQL server software. It’s evidence of a fault in some other software running on the same machine you’re using to run your python program. Error 1129 means MySQL’s crude anti-cybercriminal feature has been activated: programs running on the same machine you’re using have tried and failed to connect many times (100 by default). When that happens MySQL concludes the machine is compromised (or running amok) and refuses to accept any more connections from it.
What could cause this? Is there a cronjob or other automatically running program on your machine that’s rigged up with an invalid user name or password? If so, it might be hammering away on the MySQL server racking up connection failures.
If it’s a Linux or BSD-based machine use the ps axuww
shell command a few times and look for processes you don’t recognize. (If you’re not sure about how to do that ask on the forum for your operating system.)
You might consider rebooting the machine.
Edit Your machine seems to be under attack. You mentioned that you’re getting a lot of failed password
messages in your authlog. Can you track down the source of these attacks? If they’re internal — that is, from a machine you or your colleagues control — they are probably some kind of program that’s configured
- to run too often, or
- to use an incorrect password,
- or both.
Look for a pattern in the ip addresses. Do these failures come from one or a very few addresses? Are they from private addresses like 192.168.. or 10...*, or even from localhost (127.0.0.1)? Or do they come from all over the place? If you don’t recognize the addresses, try putting them into the forms in these three web sites:
https://ripe.net
https://apnic.net
https://arin.net
At least one of these three will tell you the country and telecom provider from which the failures are coming. If they’re from someplace where you have no relationships you are under attack.
If the attacks are external, you need to take steps to block them before they reach your database machine. Most machines running MySQL are isolated from the wider internet by firewalls because MySQL isn’t as robust as some other software against cybercriminal and script-kiddie attack.
Look for a timing pattern. Is the timing of these failures once every five minutes, or is it as rapid as possible, or what? If it’s regular, it seems likely that you have some sort of misbehaving program someplace.
If none of this makes sense to you, ask a network engineer to help you. If your MySQL server holds sensitive or valuable information, don’t delay in confronting this problem. Good luck. This kind of thing has ruined some days for me.
I have a server. And a program running on this server need to connect to one public mysql database. But recently I found the connection failed. And when I want to connect to the database by command
"mysql -h *.114.119.174 -u *****"
,
it will give a error message like this:
ERROR 1129 (HY000): Host ‘*.111.74.4’ is blocked because of many connection
errors; unblock with ‘mysqladmin flush-hosts’
The Host IP shows my server’s IP. I tried to increase the max_connect_errors to 1000000 and command mysqladmin flush-hosts but no use.
What is the problem?
Thank you.
- mysql
- remote-access
asked Jul 23, 2015 at 7:06
3
-
Have you restart the mysql server after making changes?
Jul 23, 2015 at 7:24
-
yes, I have restart it
Jul 23, 2015 at 7:27
-
What make me puzzled is will the host be blocked stop me connect to other database?
Jul 23, 2015 at 8:00
Load 7 more related questions
Show fewer related questions
For the past few days, I am getting this error every morning when I tried to connect to the MySQL database using the MySQL workbench and also through some applications. So, every day I log onto the server and run the command FLUSH HOSTS
. Then I and some machines can connect to the database and do the daily duty. The error is as follows,
Error Code: 1129 Host ‘xxx.xxx.xx.xxx’ is blocked because of many
connection errors; unblock with ‘mysqladmin flush-hosts’
The MySQL databases are in a server that running a Linux operating system (CentOS). Among other databases, we have a database that is using frequently.
Database tables are as follows,
|table 1 | 4000 records|
|table 2 | 2000 records|
|table 3 | 1500 records|
|table 4 | 35000 records|
So, the database and other tables are not working until I run the command FLUSH HOSTS
And also I am facing some slowness in table 4
. When I run SELECT * FROM table 4
query in workbench sometimes it throws this error,
Error Code: 2013. Lost connection to MySQL server during query.
So I have increased the maximum connections
, net_read_timeout
and connect_timeout
values.
table 4
has 35000
records around 5 MB
. But I don’t think the number of records is not the issue. Some of our mobile applications also throw time out errors
because of this database issue.
And also I see
waiting for table level lock
in each UPDATE, INSERT and SELECT
queries when I run the command SHOW PROCESSLIST
. And at that time table 4
is really slow. Table Engine is MyISAM
. Does that make any sense?
Note:- I have seen many questions with answers similar to this question. But they didn’t help me. So before flag this as duplicate, please read the whole question.
So anybody can help me? I am really grateful for any help.
Thanks in advance.
1 minute read
Today I had to configure a MySQL database cluster and I faced the following error
ERROR 1129 (HY000): Host '192.168.1.12' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
while I was trying to access a MySQL instance via HaProxy. After some searching in dba.stackexchange.com, I found that my failed connection attempts had surpassed the max_connect_errors variable which is set by default to 10. In order to be able to connect to the cluster again you have to follow these steps in every MySQL server that belongs to the cluster:
-
Open a command prompt (or shell in Linux) with administrative privilleges
-
If you are in Windows set character set to unicode. Linux is using UTF-8 by default.
- Flush all hosts in MySQL using mysqladmin:
mysqladmin flush-hosts -u root -p
- Open my.cnf (Linux) or my.ini (Windows) and change max_connect_errors variable to a large number. I used:
max_connect_errors= 1000000
- Restart MySQL server
Linux: sudo /etc/init.d/mysql restart
Windows: net stop mysql
net start mysql
You are done!
Issue description
After multiple successive deadline exceeded errors, on connection Open
or Ping
Error 1129
is returned and can no longer connect to the DB unless FLUSH HOSTS
is called.
Looks like #941 is causing the problem. I was able to reproduce it on 17ef3dd and 89ec2a9. But not on df597a2
Example code
package main import ( "context" "database/sql" "log" "time" "github.com/go-sql-driver/mysql" ) func main() { for { conn, err := mysql.MySQLDriver{}.OpenConnector("user:password@tcp(addr:port)/db") if err != nil { log.Fatal("OpenConnector", err) } db := sql.OpenDB(conn) err = db.Ping() if err != nil { log.Fatal("Ping", err) } for j := 0; j < 200; j++ { query(db) } log.Println("Close", db.Close()) } } func query(d *sql.DB) { ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() rows, err := d.QueryContext(ctx, "SELECT * FROM my_table") if err != nil { log.Println("QueryContext", err) return } defer rows.Close() }
Logs
....
2020/01/21 11:40:55 QueryContext context deadline exceeded
2020/01/21 11:40:55 QueryContext context deadline exceeded
2020/01/21 11:40:55 QueryContext context deadline exceeded
2020/01/21 11:40:55 QueryContext context deadline exceeded
2020/01/21 11:40:55 QueryContext context deadline exceeded
2020/01/21 11:40:55 Close <nil>
2020/01/21 11:40:55 PingError 1129: Host '10.9.10.189' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
Process finished with exit code 1
Configuration
Driver version (or git SHA): 1.5.0 17ef3dd
Go version: go version go1.13.4 darwin/amd64
Server version: 10.1.34-MariaDB