使用通配符主机的MariaDB授予权限不起作用

时间:2015-10-10 09:37:59

标签: mysql mariadb

我正在使用5.5.35-MariaDB Server进行openstack keystone安装。

以下两个命令用于插入用户keystone的权限:

GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
flush privileges;

但是在指定主机名时遇到了访问拒绝问题,主机名写在/ etc / hosts文件中。虽然使用'localhost'的访问工作正常。

[root@controller mariadb]# mysql -ukeystone -pkeystone -hcontroller
ERROR 1045 (28000): Access denied for user 'keystone'@'controller' (using password: YES)

[root@controller mariadb]# mysql -ukeystone -pkeystone -hlocalhost
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 98
Server version: 5.5.35-MariaDB MariaDB Server

我的解决方法是明确授予主机名权限,然后它正在运行:

GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'controller' IDENTIFIED BY 'keystone';

这是正常行为,因为上面的通配符'%'不起作用吗?

更新

查询结果为:

MariaDB [(none)]> SELECT User, Host FROM mysql.user WHERE User = 'keystone';
+----------+-----------+
| User     | Host      |
+----------+-----------+
| keystone | %         |
| keystone | localhost |
+----------+-----------+
2 rows in set (0.00 sec)

,ip地址和主机名如下:

[root@controller rc]# ip address show Mgmt | grep inet
inet 10.0.10.101/24 brd 127.255.255.255 scope global Mgmt
inet6 fe80::a00:27ff:fe9e:6e1a/64 scope link

[root@controller rc]# cat /etc/hosts | grep controller
10.0.10.101 controller

1 个答案:

答案 0 :(得分:0)

显式用户主机名而不是“localhost”。它解决了1045错误。

授予keystone上的所有特权。*''keystone'@'controller'通过'keystone'识别;