You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SHOW GRANTS FOR 'root'@'%'; -- show grants for a specific user
176
162
```
177
163
178
-
To be more precise, you can check the privilege information in the `Grant` table. For example, you can use the following steps to check if the `test@%` user has the `Insert` privilege on `db1.t`:
179
-
180
-
1. Check if `test@%` has global `Insert` privilege:
164
+
For example, create a user `rw_user@192.168.%` and grant the user with write privilege on the `test.write_table` table and global read privilege.
181
165
182
-
```sql
183
-
SELECT Insert_priv FROM mysql.user WHERE user='test' AND host='%';
184
-
```
185
-
186
-
2. If not, check if `test@%` has database-level `Insert` privilege at `db1`:
187
-
188
-
```sql
189
-
SELECT Insert_priv FROM mysql.db WHERE user='test' AND host='%';
190
-
```
166
+
```sql
167
+
CREATEUSER `rw_user`@`192.168.%`;
168
+
GRANTSELECTON*.* TO `rw_user`@`192.168.%`;
169
+
GRANT INSERT, UPDATEON`test`.`write_table` TO `rw_user`@`192.168.%`;
170
+
```
191
171
192
-
3. If the result is still empty, check whether `test@%` has table-level `Insert` privilege at `db1.t`:
172
+
Show granted privileges of the `rw_user@192.168.%`user:
193
173
194
-
```sql
195
-
SELECT table_priv FROM mysql.tables_priv WHERE user='test' AND host='%' AND db='db1';
| Process |`ProcessPriv`| Displays the running task |
217
206
| Execute |`ExecutePriv`| Executes the `EXECUTE` statement |
@@ -268,6 +257,10 @@ Requires the `INDEX` privilege for the table.
268
257
269
258
Requires the `DROP` privilege for the table.
270
259
260
+
### LOAD DATA
261
+
262
+
Requires the `INSERT` privilege for the table.
263
+
271
264
### TRUNCATE TABLE
272
265
273
266
Requires the `DROP` privilege for the table.
@@ -286,6 +279,8 @@ Requires the `INSERT` and `SELECT` privileges for the table.
286
279
287
280
`SHOW CREATE VIEW` requires the `SHOW VIEW` privilege.
288
281
282
+
`SHOW GRANTS` requires the `SELECT` privilege to the `mysql` database. If the target user is current user, `SHOW GRANTS` does not require any privilege.
283
+
289
284
### CREATE ROLE/USER
290
285
291
286
`CREATE ROLE` requires the `CREATE ROLE` privilege.
@@ -306,9 +301,31 @@ Requires the `CREATE USER` privilege.
306
301
307
302
Requires the `GRANT` privilege with the privileges granted by `GRANT`.
308
303
304
+
Requires additional `CREATE USER` privilege to create a user implicitly.
305
+
306
+
`GRANT ROLE` requires `SUPER` privilege.
307
+
309
308
### REVOKE
310
309
311
-
Requires the `SUPER` privilege.
310
+
Requires the `GRANT` privilege and those privileges targeted by the `REVOKE` statement.
311
+
312
+
`REVOKE ROLE` requires `SUPER` privilege.
313
+
314
+
### SET GLOBAL
315
+
316
+
Requires `SUPER` privilege to set global variables.
317
+
318
+
### ADMIN
319
+
320
+
Requires `SUPER` privilege.
321
+
322
+
### SET DEFAULT ROLE
323
+
324
+
Requires `SUPER` privilege.
325
+
326
+
### KILL
327
+
328
+
Requires `SUPER` privilege to kill other user sessions.
0 commit comments