问题描述:
用户已建,权限已赋予。long long ago这个用户是可以正常访问的,但是今天它就不能访问了。报错如下:
ERROR 1045 (28000): Access denied for user 'lf'@'172.17.215.11' (using password: YES)
排障过程:
select user,host,password from mysql.user; …. | lf| localhost | *5A4CAF734551B5347FEC1171CEB89D503693C1B4 | +--------------+---------------+-------------------------------------------+ select password(‘LF98$xxi’); +-------------------------------------------+ | password('LF98$xxi') | +-------------------------------------------+ | *5A4CAF734551B5347FEC1171CEB89D503693C1B4 | +-------------------------------------------+ 1 row in set (0.05 sec)
但是登录就是报错
[root@vhost02 ~]# mysql -ulf -pLF98$xxi Warning: Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'lf'@'localhost' (using password: YES)
难道是权限没有刷新?
[root@vhost02 ~]# mysql -uroot -p ... mysql>flush privileges;
重新登录仍然失败。。。
最终解决方式:
就在小编半晕半醒之间忽然灵光一现,用户名和密码分开输入吧,于是:
[root@vhost02 ~]# mysql -ulf -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 180 Server version: 5.6.25-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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>
成功登录了。原因居然是密码里含有$符号。特殊字符需要慎用,用不好就把自己给坑了。不过密码有$符号,并不影响它在脚本,程序里的使用。$的特殊性应该和系统命令有关。