ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this oper


1  用以往的mysql登陸模式登陸

[mysql@eanintmydbc002db1 mysqllog]$ mysql 

Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3157186
Server version: 5.5.25a-log MySQL EA Release


Copyright (c) 2000, 2011, 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> select current_user();
+----------------+
| current_user() |
+----------------+
| @localhost     |
+----------------+
1 row in set (0.01 sec)


mysql> 
mysql> 



2 奇怪,再次登陸試試看

[mysql@xxxmydbc002db1 mysqllog]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3157145
Server version: 5.5.25a-log MySQL EA Release


Copyright (c) 2000, 2011, 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> show processlist;
ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| @localhost     |
+----------------+
1 row in set (0.00 sec)

看到這里竟然沒有用戶名,只有ip地址為localhost,好詭異的狀況,看下當前所有的進程


mysql> show full processlist;
ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
mysql> 


3 去用標准的登陸模式mysql -uroot -p -hlocalhost登陸試下,看看問題到底在哪里。

[novamysqladminint@xxmydbc002db1 ~]$ mysql -uroot -p -hlocalhost
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3257823
Server version: 5.5.25a-log MySQL EA Release


Copyright (c) 2000, 2011, 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> select user,host from mysql.user;
+--------------+-------------------------------------+
| user         | host                                |
+--------------+-------------------------------------+
| mmm_agent    | %                                   |
| mmm_monitor  | %                                   |
| replication  | %                                   |
| root         | %                                   |
| root         | 127.0.0.1                           |
| root         | ::1                                 |
|              | localhost                           |  有這個用戶的,那就查下用戶到底是啥權限.
| nuc_monitor  | xx.xx.abn-iad.xx.com |
| nuc_monitor  | xx.xx.abn-iad.xx.com |
+--------------+-------------------------------------+
23 rows in set (0.00 sec)


mysql> show grants for ''@'localhost';
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |  看到這里,這個用戶只賦予了useage權限,可以connect上面,但是做不了任何操作。
+--------------------------------------+
1 row in set (0.00 sec)


mysql> 

解決方案:這個表示你的權限已經被收回了.但是user表里面還有你的記錄.你需要做的是,重新賦予這個用戶權限或者 drop掉這個無用的帳號換一個標准的帳號登陸。


Why ?

在binlog里面去查看了操作記錄以及自己平時的工作記錄,發現當時一個同事在清理帳號的時候,remove了''@'localhost'的權限,但是沒有drop 掉這個用戶,所以在默認mysql登陸的時候,優先選擇了''@'localhost',而不是用'root'@'localhost',但是問題來了,為什么執行mysql會優先用''@'localhost'帳號登陸,而不用'root'@'localhost'登陸呢?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM