關閉MySQL的DNS反向解析(unauthenticated user 解決辦法)

來源:互聯網
上載者:User

 代碼如下 複製代碼

mysql>show processlist;

| 20681949 | unauthenticated user | A.B.C.D:52497 | NULL | Connect | | Reading from net | NULL |
| 20681948 | unauthenticated user | W.X.Y.Z:52495 | NULL | Connect | | Reading from net | NULL |

發現有非常多的 unauthenticated user 嘗試做登入使用 mysql 的情?r ,當這種情況無限制發生時就會造成系統十分緩慢。

查閱mysql官方網站得知,這屬於官方一個系統上的特殊設定,就把他當成mysql的一個bug算了。不管連結的的方式是經過 hosts 或是 IP 的模式,他都會對 DNS 做反查 mysqld 會嘗試去反查 IP -> dns ,由於反查解析過慢,就會無法應付過量的查詢。


如果處於公網上的MySQL出現大量的非法使用者嘗試登陸的情況,給伺服器帶來的負荷是不可想像的。

解決辦法:
一、執行:

 代碼如下 複製代碼
# /usr/local/mysql/bin/mysqld_safe --skip-name-resolve --user=mysql&

二、修改MySQL的設定檔my.cnf
追加:

 代碼如下 複製代碼
[mysqld]
skip-name-resolve

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.