ERROR 1227 42000 Access denied you need at least one of

news/2024/7/7 9:52:04
               

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'登陆呢?


查询了很多资料以及与网友讨论,结果是执行mysql的时候,自动以系统sa的用户的方式去登陆,如果没有跟sa同名的mysql帐号,就优先以''登陆,如果没有,就以root帐号登陆,比如当前系统帐号是mysql,排序如下,如果sa是mysql::

1  ''@'localhost'

2  'mysql'@'localhost'

3  ''@'localhost'

4  'root'@'localhost'



           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow


http://www.niftyadmin.cn/n/3653805.html

相关文章

Web Development by Java Opensources (目錄)

這些是我曾經發表在台灣中央研究院-自由軟體鑄造場的電子報文章, 整理之後放在這裡. 以我的目標將分為三個 Milestone , M1 為 JSP/Servlet POJO solutions 的介紹, M2 為 WebServices/XML solutions 的介紹, M3 為完整的系統或是框架來介紹 !目錄PART1: 嘗試使用來自 Opensour…

zabbix3 0 2 实现发送email报警的详细过程

1,安装mail基础组件安装mail的基础组件:yum install sendmail -y …

Lession 2 : 跨越 IDE 的 Apache Ant

Java 最基礎的編譯工具就是 JDK 之中的 javac 這個編譯器,但是往往在開發一個大型的專案之時,我們通常會利用 IDE 來完成相關的程式開發、除錯、編譯及包裝的動作,進而與一些應用伺服器或是資料庫做相關的整合。但是,往往開發習慣…

Zabbix 如何实现邮件报警通知以及免费短信报警通知

前提条件:(1) zabbix服务器端已经成功安装并且运行。(2) zabbix客户端已经成功建立并且运行。1 下载并且安装msmtp软件Wget http://sourceforge.net/projects/msmtp/files/msmtp/1.4.32/msmtp-1.4.32.tar.bz2/downloadtar jxvf msmtp-1.4.32.tar.bz2cd msmtp-1.4.32…

台灣的 Web 2.0

自從無名小站 ( wretch.cc ) 被 Yahoo! 收購後, 投資客紛紛開始尋找下個標的, 有技術有抱負的團隊也紛紛提出許多有趣且前衛的 Web 2.0 網站.台灣經濟部技術處與資策會都提出有關 Web2.0 的補助方案. http://www.web20.org.tw/wp/ideas/index.htm 只要有創意點子, 就可以透過輔…

Struts 原理与应用(一)

本文是俺在公司技术会议上的演讲提纲算是一个小教程吧。Struts 原理与应用 2003年12月1日Chapter 1: MVC Architecture 介绍Struts的理论基础,MVC架构Chapter 2: J2EE N-tiers Structure介绍J2EE的n层结构以及Struts所处的位置Chapter 3: Struts Configuration Stru…

Struts原理与应用(三)

Chapter 5: Struts Work Flow Struts principle and practice 上图是Struts的工作流程,前边我们提到,所有的请求都提交给ActionServlet来处理。 ActionServlet是一个FrontController,它是一个标准的Servlet,它将request转发给Req…

mycat 瑞士军刀mycat-web详解

引言mycat从定义和分类来看,它是一个开源的分布式数据库系统,是一个实现了MySQL协议的服务器,前端用户可以把它看作是一个数据库代理,用MySQL客户端工具和命令行访问,而其后端可以用MySQL原生协议与多个MySQL服务器通信…