Forum Stats

  • 3,770,097 Users
  • 2,253,066 Discussions
  • 7,875,311 Comments

Discussions

MySQL Privilege Restriction Using Partial Revokes

User_J6P3H
User_J6P3H Member Posts: 1 Green Ribbon

MySQL version 5.7.32。


I have a user 'test'@'%' in MySQL database.

mysql> show grants for test;

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

| Grants for [email protected]%                               |

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

| GRANT SELECT ON *.* TO 'test'@'%'                       |

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


mysql> desc employees.salaries;

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

| Field   | Type  | Null | Key | Default | Extra |

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

| emp_no  | int(11) | NO  | PRI | NULL  |    |

| salary  | int(11) | NO  |   | NULL  |    |

| from_date | date  | NO  | PRI | NULL  |    |

| to_date  | date  | NO  |   | NULL  |    |

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


I want to revoke select privilege which on employees.salaries.salary.

mysql> revoke select(salary) on employees.salaries from test;

ERROR 1147 (42000): There is no such grant defined for user 'test' on host '%' on table 'salaries'


This privilege Cannot be revoked directly.

Is there any other way to achieve?

Thanks!

Answers