解決ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many問題
ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many
報(bào)錯(cuò)
ERROR 1129 (HY000): Host '27.227.134.197' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
解決
mysql> flush hosts;
如果以上報(bào)如下錯(cuò),則使用下面步驟:
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ù)量:
① 進(jìn)入Mysql數(shù)據(jù)庫(kù)查看
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ù)庫(kù)報(bào)錯(cuò)create connection SQLException,......errorCode 1129, state HY000
報(bào)錯(cuò):
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
錯(cuò)誤:
Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
原因
同一個(gè)ip在短時(shí)間內(nèi)產(chǎn)生太多(超過mysql數(shù)據(jù)庫(kù)max_connection_errors的最大值)中斷的數(shù)據(jù)庫(kù)連接而導(dǎo)致的阻塞;
解決辦法
1、提高允許的max_connection_errors數(shù)量(我使用此方法):
① 進(jìn)入Mysql數(shù)據(jù)庫(kù)查看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)報(bào)錯(cuò)沒有了,恢復(fù)正常。
持續(xù)了一段時(shí)間又報(bào)出了這種錯(cuò)誤,排查這臺(tái)服務(wù)器上的服務(wù),最后發(fā)現(xiàn)是因?yàn)橛幸粋€(gè)服務(wù)沒有創(chuàng)建數(shù)據(jù)庫(kù)用戶,所以導(dǎo)致這個(gè)服務(wù)一直連接數(shù)據(jù)庫(kù)報(bào)錯(cuò)導(dǎo)致的。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- 解決springboot項(xiàng)目啟動(dòng)報(bào)錯(cuò)Error creating bean with name dataSourceScriptDatabaseInitializer問題
- SpringBoot啟動(dòng)報(bào)錯(cuò)Whitelabel Error Page: This application has no explicit mapping for的解決方法
- MySQL報(bào)錯(cuò):Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
- 解決修復(fù)報(bào)錯(cuò)Error in render:TypeError:Cannot read properties of undefined(reading ‘ipconfig‘)問題
相關(guān)文章
Centos7下無法遠(yuǎn)程連接mysql數(shù)據(jù)庫(kù)的原因與解決
MySQL是由Oracle公司開發(fā)的開源SQL數(shù)據(jù)庫(kù)管理系統(tǒng),下面這篇文章主要給大家介紹了關(guān)于在Centos7下無法遠(yuǎn)程連接mysql數(shù)據(jù)庫(kù)的原因與解決方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧。2017-09-09MySL實(shí)現(xiàn)如等級(jí)成色等特殊順序的排序詳解
這篇文章主要為大家介紹了MySL實(shí)現(xiàn)如等級(jí)成色等特殊順序的排序詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05使用Kubernetes集群環(huán)境部署MySQL數(shù)據(jù)庫(kù)的實(shí)戰(zhàn)記錄
這篇文章主要介紹了使用Kubernetes集群環(huán)境部署MySQL數(shù)據(jù)庫(kù),主要包括編寫 mysql.yaml文件,執(zhí)行如下命令創(chuàng)建,通過相關(guān)命令查看創(chuàng)建結(jié)果,對(duì)Kubernetes部署MySQL數(shù)據(jù)庫(kù)的過程感興趣的朋友一起看看吧2022-05-05

如何使用myisamchk和mysqlcheck工具快速修復(fù)損壞的MySQL數(shù)據(jù)庫(kù)文件

使用mysql的disctinct group by查詢不重復(fù)記錄