解決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)文章
MySQL數(shù)據(jù)庫分組查詢group by語句詳解
這篇文章主要介紹了MySQL數(shù)據(jù)庫分組查詢group by語句詳解,文中含有詳細示例代碼說明解析,有需要的朋友可以借鑒參考想=下,希望能夠有所幫助2021-09-09
mysql制作外鍵出現(xiàn)duplicate?key?name錯誤問題及解決
這篇文章主要介紹了mysql制作外鍵出現(xiàn)duplicate?key?name錯誤問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02
MySQL數(shù)據(jù)庫手冊DATABASE操作與編碼(小白入門篇)
這篇文章主要介紹了MySQL數(shù)據(jù)庫手冊DATABASE操作與編碼的小白入門篇,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-05-05

