最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MySQL數(shù)據(jù)庫被鎖定的問題解決

 更新時間:2024年10月28日 11:39:17   作者:不愿透露姓名的大鵬  
本文主要介紹了MySQL數(shù)據(jù)庫被鎖定的問題解決方法,包括通過刷新錯誤連接、修改max_connection_errors的數(shù)量、執(zhí)行flush?host或者?mysqladmin?flush-hosts等方式進行解決,感興趣的可以了解一下

問題

ERROR 1129 (HY000): Host '192.168.10.10' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

問題驗證

我們嘗試連接,用命令行也連接失敗。

[clog@MC-FSB ~]$mysql -uroot -h192.168.10.18 -p
Enter password: 
ERROR 1129 (HY000): Host '192.168.10.10' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

查看日志

查看mysql數(shù)據(jù)庫的日志

tail -n 200 /var/log/mysqld.log

解決辦法

進入數(shù)據(jù)庫進行刷新錯誤連接,并且查看最大數(shù)量為100,并改為1000

修改max_connection_errors的數(shù)量為1000(立即生效)

 set global max_connect_errors = 1000;

在my.cnf中[mysqld]下添加(重啟后不失效)

max_connect_errors = 1000
[admin@wmsweb log]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1853635
Server version: 5.7.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> flush hosts;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like '%max_connect_errors%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 100   |
+--------------------+-------+
1 row in set (0.01 sec)

mysql> set global max_connect_errors=1000;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like '%max_connect_errors%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 1000  |
+--------------------+-------+
1 row in set (0.00 sec)

mysql> 

再次通過客戶端連接成功

[clog@MC-FSB ~]$mysql -uroot -h192.168.10.18 -p
Enter password: 
ERROR 1129 (HY000): Host '192.168.10.10' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
[clog@MC-FSB ~]$mysql -uroot -h192.168.10.18 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1853636
Server version: 5.7.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

根本解決辦法

解決ERROR 1129 (HY000)的方法是執(zhí)行flush host或者 mysqladmin flush-hosts,其目的是為了清空host cache里的信息,那是不是說不使用host cache就可以了?

host_cache_size的作用

缺點:當(dāng)有一個新的客戶端連接進來時,MySQL Server都要建立一個新的記錄,如果DNS解析很慢,無疑會影響性能。如果被允許訪問的主機很多,也會影響性能,這個與host_cache_size有關(guān),這個參數(shù)是5.6.5引入的。5.6.8之前默認(rèn)是128,5.6.8之后默認(rèn)是-1,基于max_connections的值動態(tài)調(diào)整。所以如果被允許訪問的主機很多,基于LRU算法,先前建立的連接可能會被擠掉,這些主機重新進來時,會再次進行DNS查詢。

優(yōu)點:通常情況下,主機名是不變的,而IP是多變的。如果一個客戶端的IP經(jīng)常變化,那基于IP的授權(quán)將是一個繁瑣的過程。因為你很難確定IP什么時候變化。而基于主機名,只需一次授權(quán)。而且,基于host cache中的失敗信息,可在一定程度上阻止外界的暴 力破 解攻擊。

關(guān)于阻止外界的暴 力破 解攻擊,涉及到max_connect_errors參數(shù),默認(rèn)為100,官方的解釋如下:

If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections.

如果某個客戶端的連接達到了max_connect_errors的限制,將被禁止訪問,并提示以下錯誤:

Host 'host_name' is blocked because of many connection errors.
Unblock with 'mysqladmin flush-hosts'
查看當(dāng)前的最大鏈接錯誤數(shù).

mysql> show variables like 'max_connect_errors';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 100   |
+--------------------+-------+
1 row in set (0.07 sec)

使host cache不生效(禁用 MySQL DNS 查找)的方式有如下兩種:

A、設(shè)置 host_cache_size 為0

mysql> set global host_cache_size=0;

B、配置skip-name-resolve 

編輯mysql配置文件 my.cnf

vi /etc/my.cnf

在 [mysqld] 下面添加 下面這一行

skip-name-resolve

??注意事項

但是需要注意??的是,如果這樣設(shè)置,你將沒辦法使用127.0.0.1進行連接數(shù)據(jù)庫。

如果禁用了DNS 則 localhost 則不會解析成回環(huán)地址.登錄報錯.

[root@dbserver ~]# mysql -h127.0.0.1 -u root -p         
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)

如果該參數(shù)設(shè)置為OFF,則上述方式就會報錯,通過報錯信息可以看出,它直接將127.0.0.1轉(zhuǎn)化為localhost了。

[root@localhost ~]# mysql -uroot -h127.0.0.1 -p123456 -P3306
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

到此這篇關(guān)于MySQL數(shù)據(jù)庫被鎖定的問題解決的文章就介紹到這了,更多相關(guān)MySQL數(shù)據(jù)庫被鎖定內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

彰化市| 清苑县| 泰兴市| 全椒县| SHOW| 怀集县| 略阳县| 潢川县| 唐海县| 武平县| 田东县| 普格县| 鲁甸县| 武川县| 南部县| 隆安县| 桂阳县| 闽侯县| 始兴县| 普陀区| 上杭县| 清水河县| 丹寨县| 英吉沙县| 台中市| 呼图壁县| 仙桃市| 康平县| 吴旗县| 怀化市| 阜阳市| 南江县| 洛阳市| 尖扎县| 确山县| 新竹市| 仙游县| 贵阳市| 武汉市| 白沙| 定安县|