mysql用户的host设置了%,可是登录不进去

jack_jones 发布于 2015/10/31 10:33
阅读 3K+
收藏 0

mysql> create user 'cloud'@'%' identified by '123456789';
Query OK, 0 rows affected (0.00 sec)

mysql> select host, user from user;
+-----------+-------+
| host      | user  |
+-----------+-------+
| %         | cloud |
| %         | root  |
| 127.0.0.1 | root  |
| ::1       | root  |
| localhost |       |
| localhost | root  |
| mysqltest |       |
| mysqltest | root  |
+-----------+-------+
8 rows in set (0.00 sec)

mysql> grant all privileges on txd.* to 'cloud'@'%' identified by '123456789' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye



# mysql -ucloud -p123456789
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'cloud'@'localhost' (using password: YES)



登录不进去

加载中
0
莫铭
莫铭

ERROR 1045 (28000): Access deniedfor user'cloud'@'localhost' (using password: YES)

localhost在mysql中是不会映射为127.0.0.1的。而%是指所有IP。localhost不是IP。

解决办法就是,create user 'cloud'@'localhost' .....


0
Feng_Yu
Feng_Yu
尽量不要加with grant这个权限
0
whaon
whaon
1L正解
0
世贸组织
世贸组织

在授权的时候这样写:

grant all privileges on txd.* to cloud identified by '123456789';

把 'cloud'@'%' 变成 cloud 方可,你自己测试下。

返回顶部
顶部