After granting permissions to a single table, Navicat does not display the database containing that table

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 单表授权后,Navicat没有显示该表所在的数据库

| username: Zealot

【TiDB Usage Environment】Production Environment
【TiDB Version】7.1.2
【Reproduction Path】
grant select on db_1.test to ‘user’@‘%’;
【Encountered Problem: Problem Phenomenon and Impact】
The db_1 database is not displayed in Navicat, but executing show databases shows db_1. Navicat retrieves database information through the SQL query SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA. Executing this SQL query does not return db_1.

| username: Billmay表妹 | Original post link

This might be because Navicat uses the SQL query SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA to retrieve database information, but this query does not return the database db_1 that you have been granted access to.

This is because in TiDB, granting permissions only affects the user’s permissions on tables and does not change the database metadata information. Therefore, even if you have granted SELECT permission on the table db_1.test, the information in the database metadata still does not include db_1.

Although Navicat may not display db_1 when retrieving database information, you can still view the database list by executing the SHOW DATABASES command, which should include db_1.

If you need to display the database db_1 in Navicat, you can try reconnecting to TiDB or executing the SHOW DATABASES command in Navicat to refresh the database list.

| username: Fly-bird | Original post link

My cousin is becoming more and more professional.

| username: Kongdom | Original post link

I have encountered this situation with DBeaver before. You can refresh the connection or reconnect, and it should work.

| username: Zealot | Original post link

It doesn’t work in Navicat mainly because there is no corresponding value in information_schema.SCHEMATA. This phenomenon does not exist in MySQL either. I think it’s a bug.

| username: zxgaa | Original post link

Refresh or reconnect.

| username: 啦啦啦啦啦 | Original post link

I roughly understand what you mean. If you only grant permissions to a single table, you won’t be able to see the database information in SCHEMATA. In TiDB, it seems that you need whole database permissions to see the database name in SCHEMATA. I just tested it, and it does seem to be somewhat inconsistent with MySQL. I’m not sure if this is the expected behavior.

| username: TiDBer_小阿飞 | Original post link

Since the schema is not displayed, does this mean that the statement to grant query permissions was unsuccessful?

| username: 啦啦啦啦啦 | Original post link

No, the authorization was successful. Querying data and using “show databases” are both fine. It’s just that the corresponding database name cannot be seen in information_schema.SCHEMATA. The authentication here seems to be different from MySQL.

| username: Kongdom | Original post link

:thinking: That could indeed be a bug.

| username: Jolyne | Original post link

You need to set this up in Navicat, manually add the database you authorized, and then refresh it to see the database with the single table you authorized.

| username: Zealot | Original post link

This method works, and I am currently doing the same, but it is still inconvenient.

| username: Kongdom | Original post link

You can try switching to DBeaver. I switched from Navicat to DBeaver myself.

| username: Jolyne | Original post link

Try both DBeaver and DataGrip. Currently, Navicat can only be used this way.

| username: andone | Original post link

Try using SQLyog.