如何将MySQL用户限制为特定表 [英] How can I restrict a MySQL user to a particular tables

查看:321
本文介绍了如何将MySQL用户限制为特定表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将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_Userstb_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用户限制为特定表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆