MySQL权限查看所有数据库?

为此,语法如下-

revoke show databases on *.* from 'yourUserName'@'yourHostName';

让我们显示所有用户名以及主机名-

mysql> select user,host from MySQL.user;

这将产生以下输出-

+------------------+-----------+

| user             | host      |

+------------------+-----------+

| Bob              | %         |

| Charlie          | %         |

| Robert           | %         |

| User2            | %         |

| mysql.infoschema | %         |

| mysql.session    | %         |

| mysql.sys        | %         |

| root             | %         |

| @UserName@       | localhost |

| Adam             | localhost |

| Adam Smith       | localhost |

| Chris            | localhost |

| David            | localhost |

| James            | localhost |

| John             | localhost |

| John Doe         | localhost |

| Michael          | localhost |

| Mike             | localhost |

| User1            | localhost |

| am               | localhost |

| hbstudent        | localhost |

| mysql.infoschema | localhost |

| mysql.session    | localhost |

+------------------+-----------+

23 rows in set (0.00 sec)

这是查看特定用户的所有授权的查询-

mysql> show grants for 'John'@'localhost';

这将产生以下输出-

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

| Grants for John@localhost                                                                                                                                                                                                                                                                                                                                                              |

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `John`@`localhost` |

| GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `John`@`localhost`                                                                                                  |

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

2 rows in set (0.07 sec)

这是具有查看所有数据库权限的查询。要显示所有数据库,我们使用show database命令-

mysql> revoke show databases on *.* from 'John'@'localhost';

以上是 MySQL权限查看所有数据库? 的全部内容, 来源链接: utcz.com/z/340849.html

回到顶部