数据库对库授权 _不能识别

【 TiDB 使用环境】 /测试/
【 TiDB 版本】6.1.1
【复现路径】GRANT ALL PRIVILEGES ON test_%.* TO ‘test’@‘%’;
【遇到的问题:对数据库授权如果只写test可以识别 test_1 这个库,如果test_ 就不能找不到这个库了。这个语法在mysql是可以的。tidb写 试过转义 GRANT ALL PRIVILEGES ON test\_%.* TO ‘test’@‘%’; 都不行 这个BUG 还是不支持这个语法】
【资源配置】
【附件:截图/日志/监控】

参考:

https://docs.pingcap.com/zh/tidb/stable/privilege-management

这个里面没有 能解决我的问题的 我的是 test_% 是下划线识别不了 test%是可以的

CREATE USER test@‘%’ IDENTIFIED BY ‘Asia_6796’;
GRANT ALL PRIVILEGES ON z_%.* TO test@‘%’;

我试试可以的啊,
image

GRANT ALL PRIVILEGES ON ds_%.* TO ‘dspirate’@‘%’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 29 near “%.* TO ‘dspirate’@‘%’”

按照你的写 我这语法报错了 你的版本是多少的

其他库为啥能显示出来,不应该只是显示“z_1”的库吗

GRANT ALL PRIVILEGES ON ds_%.* TO dspirate@‘%’; 我的语法是这样的

你应该先创建用户CREATE USE,然后执行grant,直接grant 不能创建用户并且会报错

用户是有的


image
ds_ 的看不到

我现在能理解的就是这个_ 是一个通配符 但是没有通配到 下划线这个字符串 怎么把这个转义成下划线 \试过了

这个是有中文引号的问题吧

  • % 匹配所有字符
  • _ 匹配一个任意字符

建议参考下这个文章:https://mp.weixin.qq.com/s/s0DsJhghy2GWrHZt9xu87g

还没解决 发现这个_这里就是一个 通配符 怎么能转义成下划线
GRANT ALL PRIVILEGES ON ds\_%.* TO ‘test’@‘%’; 这种方式试过了

GRANT ALL PRIVILEGES ON s\_%.* TO test@‘%’;注意`这个符号啊

好像是论坛的问题,这个符号不显示,你需要把s\_%用两个包起来

测了下,感觉这块像是有bug

官网描述:

测试: 版本 6.5.0

mysql> select version();
+--------------------+
| version()          |
+--------------------+
| 5.7.25-TiDB-v6.5.0 |
+--------------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| METRICS_SCHEMA     |
| PERFORMANCE_SCHEMA |
| fl                 |
| mysql              |
| test               |
| test_              |
| test_1             |
| test_2             |
| test_2222          |
| tpch               |
+--------------------+
11 rows in set (0.01 sec)

mysql> create user lf@'%'  identified by 'lf';
Query OK, 0 rows affected (0.08 sec)

mysql>
mysql> grant all on `test\%`.* to lf@'%';
Query OK, 0 rows affected (0.06 sec)

mysql> show grants for lf@'%';
+----------------------------------------------+
| Grants for lf@%                              |
+----------------------------------------------+
| GRANT USAGE ON *.* TO 'lf'@'%'               |
| GRANT ALL PRIVILEGES ON test\%.* TO 'lf'@'%' |
+----------------------------------------------+
2 rows in set (0.00 sec)

mysql>
mysql> exit
Bye
[tidb@qa-fenglei-01 ~]$ mysql -h10.18.13.224 -P3399 -ulf -plf
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 721
Server version: 5.7.25-TiDB-v6.5.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
+--------------------+
1 row in set (0.01 sec)

mysql>


image
我的版本5.4.3,通过上面红框给test赋权,test能看见u_1,但是看不见universe,是没问题的,6.5我没试

目前使用的6.1 确定是有问题的。但是不知道是什么原因,我多次进行REVOKE grant权限操作。
e2fcfaea983f3cfabf4639c9116490e8
可以肯定的是两个用户权限一样 但是看到的内容不一样。后来我把有问题那个用户删除了。然后重建用户给权限。就行了。。难道是缓存了么?这个也很难复现 。