[MySQL故障] ERROR 1045 (28000): Access denied for user 'mmm_agent'@'exxx-tx.com' (using password: YES

1 error登陆错误
  1. [uxxx@exxx-0702 ~]$ mysql -hexxx-tx.com --user='mmm_agent' --password='#tx$'  
  2. ERROR 1045 (28000): Access denied for user 'mmm_agent'@'exxx-tx.com' (using password: YES)  




2 去掉-h参数,能顺利登陆 
  1. [uxxx@exxx-0702 ~]$ mysql --user='mmm_agent' --password='#tx$'  
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  3. Your MySQL connection id is 491  
  4. Server version: 5.x.xa-log MySQL tx Reltxse  
  5.   
  6.   
  7. Copyright (c) 20002011, Oracle and/or its affiliates. All rights reserved.  
  8.   
  9.   
  10. Oracle is a registered trademark of Oracle Corporation and/or its  
  11. affiliates. Other names may be trademarks of their respective  
  12. owners.  
  13.   
  14.   
  15. Type 'help;' or '\h' for help. Type '\c' to cltxr the current input statement.  
  16.   
  17.   
  18. mysql>  




3 难道是对于-h参数有限制?我换个用户试试看
  1. mysql> GRANT ALL PRIVILEGES ON *.* TO 'mg'@'%' IDENTIFIED BY '#tx$';  
  2. Query OK, 0 rows affected (0.01 sec)  
  3.   
  4.   
  5. mysql> exit  
  6. [uxxx@exxx-0702 ~]$ mysql -hexxx-tx.com --user='mg' --password='#tx$'  
  7. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  8. Your MySQL connection id is 965  
  9. Server version: 5.x.xa-log MySQL tx Reltxse  
  10.   
  11.   
  12. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.  
  13.   
  14.   
  15. Oracle is a registered trademark of Oracle Corporation and/or its  
  16. affiliates. Other names may be trademarks of their respective  
  17. owners.  
  18.   
  19.   
  20. Type 'help;' or '\h' for help. Type '\c' to cltxr the current input statement.  
  21.   
  22.   
  23. mysql>   

看来不是对于-h参数的限制问题,应该是别的故障,密码是OK的。


4 去查看mmm_agent用户吧。
  1. mysql> select user,host from mysql.user where user='mmm_agent';  
  2. +-----------+------+  
  3. user      | host |  
  4. +-----------+------+  
  5. | mmm_agent | %    |  
  6. | mmm_agent | 10.% |  
  7. +-----------+------+  
  8. rows in set (0.00 sec)  
  9.   
  10.   
  11. mysql> show grants for mmm_agent@'%';  
  12. +-------------------------------------------------------------------------------------------------------------------+  
  13. | Grants for mmm_agent@%                                                                                            |  
  14. +-------------------------------------------------------------------------------------------------------------------+  
  15. GRANT ALL PRIVILEGES ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY PASSWORD '*77074D8AC9603904375ED54F1D2E14CDACB7842F' |  
  16. +-------------------------------------------------------------------------------------------------------------------+  
  17. 1 row in set (0.00 sec)  
  18.   
  19.   
  20. mysql> show grants for mmm_agent@'10.%';  
  21. +--------------------------------------------------------------------------------------------------------------------------------------------------+  
  22. | Grants for mmm_agent@10.%                                                                                                                        |  
  23. +--------------------------------------------------------------------------------------------------------------------------------------------------+  
  24. GRANT RELOAD, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'mmm_agent'@'10.%' IDENTIFIED BY PASSWORD '*6745119376CF6BD5E0F0A50484A91AE7BD172612' |  
  25. GRANT EXECUTE ON `audit`.* TO 'mmm_agent'@'10.%'                                                                                                 |  
  26. +--------------------------------------------------------------------------------------------------------------------------------------------------+  
  27. rows in set (0.00 sec)  
  28.   
  29.   
  30. mysql>   




-- 看到这里有2个帐号,相同 用户名,不同host,而且密码也不相同,那么我将host为10.%的mmm_agent用户的密码修改成与host为%的mmm_agent用户一样的密码,试试看。
  1. GRANT RELOAD, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'mmm_agent'@'10.%' IDENTIFIED BY '#tx$';  
  2. GRANT EXECUTE ON `audit`.* TO 'mmm_agent'@'10.%'   
  3.   
  4.   
  5. mysql> GRANT RELOAD, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'mmm_agent'@'10.%' IDENTIFIED BY '#tx$';  
  6. Query OK, 0 rows affected (0.01 sec)  
  7.   
  8.   
  9. mysql> GRANT EXECUTE ON `audit`.* TO 'mmm_agent'@'10.%'   
  10.     -> ;  
  11. Query OK, 0 rows affected (0.00 sec)  
  12.   
  13.   
  14. mysql> exit  
  15. Bye  
  16. [uxxx@exxx-0702 ~]$ mysql -hexxx-tx.com --user='mmm_agent' --password='#tx$'  
  17. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  18. Your MySQL connection id is 1191  
  19. Server version: 5.x.xa-log MySQL tx Reltxse  
  20.   
  21.   
  22. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.  
  23.   
  24.   
  25. Oracle is a registered trademark of Oracle Corporation and/or its  
  26. affiliates. Other names may be trademarks of their respective  
  27. owners.  
  28.   
  29.   
  30. Type 'help;' or '\h' for help. Type '\c' to cltxr the current input statement.  
  31.   
  32.   
  33. mysql>   
  1. -- 用-h参数登陆mysql成功了。  




[总结]:

嗯,可以了,使用[uxxx@exxx-0702 ~]$ mysql -hexxx-tx.com --user='mmm_agent' --password='#tx$' 登陆成功了。


mysql在调用-h参数的时候,如果用户名相同,在host的选择上面,先去匹配范围小的用户,在这个案例中, %比10.%的范围要大得多,所以再用 -hexxx-tx.com -ummm_agent访问的时候直接匹配范围小的10.%用户了,而恰巧mmm_agent@'10.%'用户的密码与mmm_agent@'%'用户的密码不是一样的,就报了如下密码错误的提示:

ERROR 1045 (28000): Access denied for user 'mmm_agent'@'%' (using password: YES)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值