问题描述
如何将MySQL数据库中的user_account限制为特定表.例如:
How can I restrict a user_account in MySQL database to a particular tables. Ex:
UserName: RestrictedUser
DatabaseName: db_Payroll
TableName:
tb_Employees
tb_Users
tb_Payroll_YYMMDD
tb_Payroll_Processed
我只想将"RestrictedUser"限制为tb_Users
和tb_Employees
,并且将为将来使用而创建的db_Payroll
其余表授予访问权限.
I want to restrict "RestrictedUser" to tb_Users
and tb_Employees
only and the rest of the tables of db_Payroll
that will be created for future use is granted to have access.
推荐答案
假设用户没有当前权限,则可以执行以下操作
Assuming the user has no current privileges, you can do the following
GRANT SELECT, INSERT, DELETE ON db_Payroll.tb_Users TO RestrictedUser@'%'
GRANT SELECT, INSERT, DELETE ON db_Payroll.tb_Employees TO RestrictedUser@'%'
根据要授予用户的特权,可以将SELECT, INSERT, DELETE
更改为其他内容,例如ALL PRIVILEGES
.
Depending on exactly which privileges you wish to grant the user, you can change SELECT, INSERT, DELETE
to something else, e.g. ALL PRIVILEGES
.
此后,请记住清除特权以使其生效.
Afterwards, remember to flush the privileges to they become effective.
FLUSH PRIVILEGES;
这篇关于如何将MySQL用户限制为特定表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!