MariaDB显示数据库权限

时间:2017-11-08 13:47:59

标签: mysql mariadb

在控制台SHOW DATABASES;中运行我收到错误:

ERROR 1227 (42000): Access denied; you need (at least one of) the SHOW DATABASES privilege(s) for this operation

我已使用SHOW GRANTS FOR CURRENT_USER;检查了用户权限,似乎我拥有所有权限:

GRANT USAGE ON *.* TO 'tec'@'%' IDENTIFIED BY PASSWORD ' *F0AAB5B469***16C3449'

GRANT ALL PRIVILEGES ON `tec`.* TO 'tec'@'%' 

可能是什么原因?

Server version: 10.0.32-MariaDB-0+deb8u1 (Debian)

1 个答案:

答案 0 :(得分:0)

我无法重现这个问题:

$ mysql -u tec -p
Enter password:
MariaDB [(none)]> SELECT VERSION(), CURRENT_USER();
+-----------------+----------------+
| VERSION()       | CURRENT_USER() |
+-----------------+----------------+
| 10.0.33-MariaDB | tec@%          |
+-----------------+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW GRANTS FOR CURRENT_USER;
+--------------------------------------------------------------------------------+
| Grants for tec@%                                                               |
+--------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'tec'@'%' IDENTIFIED BY PASSWORD '*F0AAB5B469***16C3449' |
| GRANT ALL PRIVILEGES ON `tec`.* TO 'tec'@'%'                                   |
+--------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| tec                |
+--------------------+
2 rows in set (0.01 sec)

<强>更新

检查skip_show_database服务器系统变量。

<强>的my.cnf

...

[mysqld]
...
skip_show_database
...
$ mysql -u tec -p
Enter password:
MariaDB [(none)]> SELECT VERSION(), CURRENT_USER();
+-----------------+----------------+
| VERSION()       | CURRENT_USER() |
+-----------------+----------------+
| 10.0.33-MariaDB | tec@%          |
+-----------------+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW GRANTS FOR CURRENT_USER;
+--------------------------------------------------------------------------------+
| Grants for tec@%                                                               |
+--------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'tec'@'%' IDENTIFIED BY PASSWORD '*F0AAB5B469***16C3449' |
| GRANT ALL PRIVILEGES ON `tec`.* TO 'tec'@'%'                                   |
+--------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> SHOW DATABASES;
ERROR 1227 (42000): Access denied; you need (at least one of) the SHOW DATABASES privilege(s) for this operation

更新2

MariaDB [(none)]> SHOW VARIABLES
    -> WHERE `Variable_name` = 'skip_show_database';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| skip_show_database | ON    |
+--------------------+-------+
1 row in set (0.00 sec)