今天碰到一个简单又白痴的问题(5.6 % 和localhost有区别)
mysql 5.6 新建用户后无法登录
ERROR 1045 (28000): Access denied for user 'zabbixadmin'@'localhost' (using password: YES)
mysql> GRANT USAGE,PROCESS,SELECT,SUPER,REPLICATION CLIENT,REPLICATION SLAVE ON *.* TO 'zabbixadmin'@'%' IDENTIFIED BY 'zabbixadmin';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select User ,Host,Password from mysql.user;
+--------------+---------------+-------------------------------------------+
| User | Host | Password |
+--------------+---------------+-------------------------------------------+
| root | localhost | *F7E3C9A16B2841BF7A52760C027129A2BCA2F47E |
| root | zsgassmysql01 | *F7E3C9A16B2841BF7A52760C027129A2BCA2F47E |
| root | 127.0.0.1 | *F7E3C9A16B2841BF7A52760C027129A2BCA2F47E |
| root | ::1 | *F7E3C9A16B2841BF7A52760C027129A2BCA2F47E |
| | localhost | |
| | zsgassmysql01 | |
| root | % | *F7E3C9A16B2841BF7A52760C027129A2BCA2F47E |
| zabbixadmin | % | *F00B78436E89EDBE88F52F781EFDA84C2C8782E4 |
+--------------+---------------+-------------------------------------------+
18 rows in set (0.00 sec)
-bash-4.1$ mysql -uzabbixadmin -p
Enter password:
ERROR 1045 (28000): Access denied for user 'zabbixadmin'@'localhost' (using password: YES)
-bash-4.1$ mysql -uzabbixadmin -h 10.182.34.xxx -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1382
Server version: 5.6.14-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2013, 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> exit
--成功
%不是可以任意主机登录吗,结果一查发现,5.7开始才是,5.6不行,如果要本地登录,需要localhost ,踩了好几次坑了,今天终于找到了,不是秘密问题,也不需要配置免密码登录,然后去改密码。