MySQL Host is blocked because of many connection errors 解決方法

應用日誌提示錯誤:
create connection error, url: jdbc:mysql://10.45.236.235:3306/db_wang?useUnicode=true&characterEncoding=UTF-8, errorCode 1129, state HY000java.sql.SQLException: null, message from server: "Host '10.30.174.183' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"java

緣由:mysql

  同一個ip在短期內產生太多(超過mysql數據庫max_connection_errors的最大值)中斷的數據庫鏈接而致使的阻塞;sql

解決方法:數據庫

一、提升容許的max_connect_errors數量(這種方法不完全,後期還可能致使異常出現):url

  進入Mysql數據庫查看max_connect_errors: show variables like 'max_connect_errors';spa

    修改max_connect_errors的數量爲1000: set global max_connect_errors = 1000;日誌

    查看是否修改爲功:show variables like 'max_connect_errors';code

二、使用mysqladmin flush-hosts 命令清理一下hosts文件server

    whereis mysqladmin查找mysqladmin的路徑ip

  使用命令修改:

           /usr/bin/mysqladmin flush-hosts -h192.168.1.121 -uroot -p

  備註:

   配置有master/slave主從數據庫的要把主庫和從庫都修改一遍

   第二步也能夠在數據庫中進行,命令以下:flush hosts;        mysql> flush hosts;

相關文章
相關標籤/搜索