mysql啟用skip-name-resolve模式時出現Warning的處理辦法

賀子_DBA時代發表於2017-02-15
檢視mysql告警日誌,發現兩個警告,如下紅體字
[root@S243 ~]#  tail  -f /mysql/datadir/S243.err
2017-02-15 08:59:57 23433 [Warning] 'user' entry 'root@s243' ignored in --skip-name-resolve mode.
2017-02-15 08:59:57 23433 [Warning] 'proxies_priv' entry '@ root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:00:00 23433 [Warning] 'user' entry 'root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:00:00 23433 [Warning] 'proxies_priv' entry '@ root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:22:58 23433 [Warning] 'user' entry 'root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:22:58 23433 [Warning] 'proxies_priv' entry '@ root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:23:03 23433 [Warning] 'user' entry 'root@s243' ignored in --skip-name-resolve mode.
2017-02-15 09:23:03 23433 [Warning] 'proxies_priv' entry '@ root@s243' ignored in --skip-name-resolve mode.
網上搜到一篇文章。。。。。。,驗證確實解決了問題,於是粘過來做個記錄。
[實踐OK]mysql啟用skip-name-resolve模式時出現Warning的處理辦法 
背景:skip-name-resolve 引數的目的是不再進行反解析(ip不反解成域名),這樣可以加快資料庫的反應時間。修改配置檔案新增並需要重啟:[mysqld] skip-name-resolve新增後發現錯誤日誌有警告資訊:
[root@jackxiang mysql]# vi my.cnf
skip-name-resolve
# 禁止MySQL對外部連線進行DNS解析,使用這一選項可以消除MySQL進行DNS解析的時間。但需要注意,如果開啟該選項,
# 則所有遠端主機連線授權都要使用IP地址方式,否則MySQL將無法正常處理連線請求
實踐如下:
重啟mysql,發現日誌還有:
1)按提示作下查詢,果然有一個空賬戶和root帳戶的Host是jackxiang:
select * from user where Host="jackxiang"\G;
mysql> select Host,User,Password from user where Host="jackxiang";
+-----------+------+-----------------------------------------------------+
| Host          | User  | Password                              |
+-----------+------+-----------------------------------------------------+
| jackxiang  |           |                                                                            |
| jackxiang |root      | *2CD42BDFDF0EB0E*Z****3458EB72EE1F17F26F |
+-----------+------+------------------------------------------------------+
2)查下localhost,因為大都是限定本機連線,不讓外面機器連線,確保安全:
mysql> select Host,User,Password from user where Host="localhost" limit 2;
+-----------+-----------------+-------------------------------------------+
| Host      | User                     | Password                                               |
+-----------+-----------------+-------------------------------------------+
| localhost |                           |                                                               |
| localhost | jack_mysql          | *2CD42BDFDF0E***3458EB72EE1F17F26F |
+-----------+-----------------+-------------------------------------------+
3)把Host既是 jackxiang的,使用者是空或root的Host修改為localhost:
mysql> update user set Host="localhost" where Host="jackxiang";
ERROR 1062 (23000): Duplicate entry 'localhost-' for key 'PRIMARY'
這樣搞不行,得一個一個幹掉,看有沒有root同名的,查下:
mysql> select Host,User,Password from user where User="";
+-----------+------+----------+
| Host      | User | Password |
+-----------+------+----------+
| localhost |            |               |
| jackxiang |            |               |
+-----------+------+----------+
mysql> delete from user where  User="" and Password="";
Query OK, 2 rows affected (0.01 sec)
4)查下user為root的
mysql> select Host,User,Password from user where User="root";                                      
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *2CD42BDFDF0EB0E1A7777777777EE1F17F26F |
| jackxiang | root | *2CD42BDFDF0EB0E1A7777777777EE1F17F26F |
| 127.0.0.1 | root | *2CD42BDFDF0EB0E1A7777777777EE1F17F26F |
| ::1       | root | *2CD42BDFDF0EB0E1A7777777777EE1F17F26F |
+-----------+------+-------------------------------------------+

5)留下localhost就足夠了,其餘刪除掉:
mysql> delete from user where Host !="localhost" and User="root";
Query OK, 3 rows affected (0.00 sec)
6)restart mysql:

日誌warning還有一個:
[Warning] 'proxies_priv' entry '@ root@jackxiang' ignored in --skip-name-resolve mode.
解決辦法:
然後刪除表mysql.proxies_priv中和cvs類似與具體域名有關的行,方法同上。
mysql> select Host,User,Proxied_host,Proxied_user,With_grant,Grantor,Timestamp from proxies_priv ;
+-----------+------+--------------+--------------+------------+---------+----------------+
| Host      | User | Proxied_host | Proxied_user | With_grant | Grantor | Timestamp           |
+-----------+------+--------------+--------------+------------+---------+----------------+
| localhost | root |              |              |                              1 |         | 2014-07-14 13:26:08 |
| jackxiang | root |              |              |                              1 |         | 2014-07-14 13:26:08 |
+-----------+------+--------------+--------------+------------+---------+----------------+
mysql> delete from proxies_priv where Host="jackxiang";
Query OK, 1 row affected (0.02 sec)
這下徹底清靜了。
原來是當時安裝mysql後,多次grant授權引起的,。
備註:
  skip-name-resolve是禁用dns解析,避免網路DNS解析服務引發訪問MYSQL的錯誤,一般應當啟用。   啟用後,在mysql的授權表中就不能使用主機名了,只能使用IP ,出現此警告是由於mysql 表中已經存在有 root@jackxiang 帳號資訊。     我們把它刪除就好了。   mysql>use mysql; mysql> delete  from user where HOST='localhost.localdomain'; Query OK, 2 rows affected (0.00 sec)   重啟MYSQL ,發現警告已經沒有啦。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29654823/viewspace-2133549/,如需轉載,請註明出處,否則將追究法律責任。

相關文章