授予用户仅查看 MySQL 视图的权限,而没有其他权限 [英] Grant a user permission to only view a MySQL view and nothing else

查看:245
本文介绍了授予用户仅查看 MySQL 视图的权限,而没有其他权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题原本是用 MySQL 5.1.44 的,但也适用于 MySQL 8.0+.

This question was originally using MySQL 5.1.44, but is applicable to MySQL 8.0+ too.

假设我有一个表,其中包含由我的应用程序的不同用户插入的记录.如何授予特定用户访问权限以仅查看他/她在该表中的记录?我想过用他/她的记录创建一个 VIEW,但我不知道如何创建一个只能看到那个 VIEW 的 MySQL 用户.

Let's say I have a table with records inserted by different users of my application. How can I give a specific user access to only see his/her records in that table? I've thought about creating a VIEW with his/her records, but I don't know how to create a MySQL user that can only see that VIEW.

那么,是否可以创建一个只能访问单个 VIEW 的 MySQL 用户?是否也可以将此用户设置为对该 VIEW 进行只读访问?

So, is it possible to create a MySQL user that only has access to a single VIEW? Can this user also be made so they read-only access to that VIEW?

谢谢!

PS:在我的示例中,我所说的用户实际上是希望使用自己的应用程序访问其记录的分支机构.

PS: What I call users in my example are really subsidiary offices that want to access their records with their own applications.

推荐答案

GRANT SELECT ON database1.view1 TO 'someuser'@'somehost';

这篇关于授予用户仅查看 MySQL 视图的权限,而没有其他权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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