Skip to content

Commit ac72384

Browse files
authored
Merge pull request #411 from percona/ps-9516
PS-9516 Redo Extended SHOW GRANTS for 8.4
2 parents d5e17eb + 3011a99 commit ac72384

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

docs/extended-show-grants.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,51 @@
1-
# Extended SHOW GRANTS
1+
# Review effective privileges with SHOW EFFECTIVE GRANTS
22

3-
In Oracle *MySQL* `SHOW GRANTS` displays only the privileges granted
4-
explicitly to the named account. Other privileges might be available
5-
to the account, but they are not displayed. For example, if an
6-
anonymous account exists, the named account might be able to use its
7-
privileges, but `SHOW GRANTS` will not display them. *Percona Server for MySQL* offers the `SHOW EFFECTIVE GRANTS` command to display
8-
all the effectively available privileges to the account, including
9-
those granted to a different account.
3+
In MySQL, `SHOW GRANTS` has the following limitations:
4+
5+
* Shows only explicitly granted privileges
6+
7+
* Does not show inherited anonymous user privileges
8+
9+
* Does not show privileges inherited through roles unless the USING clause is specified
10+
11+
Other privileges might be available to the account but are not displayed. For example:
12+
13+
```{.bash data-prompt="mysql>"}
14+
-- Create named and anonymous users
15+
mysql> CREATE USER 'user1'@'localhost';
16+
mysql> CREATE USER ''@'localhost';
17+
18+
-- Grant privilege to anonymous user
19+
mysql> GRANT SELECT ON db.* TO ''@'localhost';
20+
```
21+
22+
```{.bash data-prompt="mysql>"}
23+
-- Check user1's grants
24+
mysql> SHOW GRANTS FOR 'user1'@'localhost';
25+
```
26+
??? example "Expected output"
27+
28+
```text
29+
GRANT USAGE ON *.* TO 'user1'@'localhost'
30+
```
31+
32+
33+
34+
Even though 'user1'@'localhost' can use `SELECT on db.*`, this privilege does not appear in `SHOW GRANTS`.
35+
36+
Percona Server for MySQL's `SHOW EFFECTIVE GRANTS` command provides a comprehensive view of a user's permissions. It reveals not only the privileges directly granted to the user but also those inherited from other accounts, such as anonymous users or roles. This includes system-level, database-level, and table-level privileges, giving you a complete picture of the user's access rights within the database.
37+
38+
The benefits are:
39+
40+
* Shows complete privilege picture
41+
42+
* Helps identify privilege sources
43+
44+
* Simplifies security audits
45+
46+
* Makes troubleshooting easier
47+
48+
* Reveals inherited privileges
1049

1150
## Example
1251

@@ -104,7 +143,4 @@ mysql> SHOW EFFECTIVE GRANTS;
104143
+-------------------------------------------------------------------+
105144
2 rows in set (0.00 sec)
106145
```
107-
108-
## Other reading
109-
110-
* [#53645](https://bugs.mysql.com/bug.php?id=53645) - `SHOW GRANTS` not displaying all the applicable grants
146+

0 commit comments

Comments
 (0)