解決ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many問題
ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many
報錯
ERROR 1129 (HY000): Host '27.227.134.197' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
解決
mysql> flush hosts;
如果以上報如下錯,則使用下面步驟:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-hosts' at line 1
mysql> show variables like "max_connection_errors";
1.首先使用 root 登錄 mysql -u root -p 或者
mysql -uroot -h39.97.49.66 -p
2.提高允許的max_connection_errors數(shù)量:
① 進入Mysql數(shù)據(jù)庫查看
max_connection_errors: show variables like "max_connection_errors";
② 修改max_connection_errors的數(shù)量為1000:
set global max_connect_errors = 1000;
③ 修改 max_connections 的數(shù)量為1000 :
set global max_connections = 1000;
3.最后使用 mysql> flush-hosts; 命令清理一下hosts文件;
數(shù)據(jù)庫報錯create connection SQLException,......errorCode 1129, state HY000
報錯:
com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://mysql:3306/config?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai, errorCode 1129, state HY000
錯誤:
Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
原因
同一個ip在短時間內(nèi)產(chǎn)生太多(超過mysql數(shù)據(jù)庫max_connection_errors的最大值)中斷的數(shù)據(jù)庫連接而導(dǎo)致的阻塞;
解決辦法
1、提高允許的max_connection_errors數(shù)量(我使用此方法):
① 進入Mysql數(shù)據(jù)庫查看max_connection_errors: show variables like '%max_connect_errors%';
② 修改max_connection_errors的數(shù)量為1000: set global max_connect_errors=1000;
③ 查看是否修改成功:show variables like '%max_connection_errors%';
永久性修改:vim my.cnf
修改完配置文件,重啟mysql
最后再次查看服務(wù),發(fā)現(xiàn)報錯沒有了,恢復(fù)正常。
持續(xù)了一段時間又報出了這種錯誤,排查這臺服務(wù)器上的服務(wù),最后發(fā)現(xiàn)是因為有一個服務(wù)沒有創(chuàng)建數(shù)據(jù)庫用戶,所以導(dǎo)致這個服務(wù)一直連接數(shù)據(jù)庫報錯導(dǎo)致的。
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- 解決springboot項目啟動報錯Error creating bean with name dataSourceScriptDatabaseInitializer問題
- SpringBoot啟動報錯Whitelabel Error Page: This application has no explicit mapping for的解決方法
- MySQL報錯:Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
- 解決修復(fù)報錯Error in render:TypeError:Cannot read properties of undefined(reading ‘ipconfig‘)問題
相關(guān)文章
Centos7下無法遠程連接mysql數(shù)據(jù)庫的原因與解決
MySQL是由Oracle公司開發(fā)的開源SQL數(shù)據(jù)庫管理系統(tǒng),下面這篇文章主要給大家介紹了關(guān)于在Centos7下無法遠程連接mysql數(shù)據(jù)庫的原因與解決方法,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考借鑒,下面來一起看看吧。2017-09-09使用Kubernetes集群環(huán)境部署MySQL數(shù)據(jù)庫的實戰(zhàn)記錄
這篇文章主要介紹了使用Kubernetes集群環(huán)境部署MySQL數(shù)據(jù)庫,主要包括編寫 mysql.yaml文件,執(zhí)行如下命令創(chuàng)建,通過相關(guān)命令查看創(chuàng)建結(jié)果,對Kubernetes部署MySQL數(shù)據(jù)庫的過程感興趣的朋友一起看看吧2022-05-05如何使用myisamchk和mysqlcheck工具快速修復(fù)損壞的MySQL數(shù)據(jù)庫文件
有時候數(shù)據(jù)庫突然就壞了很郁悶,用mysqlcheck.exe可以修復(fù)受損數(shù)據(jù)庫2020-01-01使用mysql的disctinct group by查詢不重復(fù)記錄
非常不錯的方法,用mysql的group by解決不重復(fù)記錄的問題,看來我需要學(xué)習(xí)的地方太多了2008-08-08