mysql用户行级访问 [英] mysql user row level access

查看:57
本文介绍了mysql用户行级访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有具有以下内容的数据库

Have a database with the following

id | userid | name
1  |    1   | John
2  |    1   | John
3  |    2   | Joe
4  |    2   | Joe
5  |    2   | Joe
6  |    3   | Sue
7  |    3   | Sue

我需要一种创建数据库然后创建用户的方法.我在mysql中创建的每个用户都限制了他们对其userid的数据访问.数据库中的每个数据库表都有userid值.

I need to get a way that I can create a database, then create users. Each user that I create in mysql limit them to access of data for their userid. Every database table in the database has the userid value.

因此,无论他们正在阅读,更新,插入还是删除.如果要通过我附加到该数据库的特定mysql用户,我希望该用户仅读取,更新,插入或删除其用户ID所在的位置.

So whether they are reading ,updating, insert or delete. If it is going through a specific mysql user that I attached to that database, I want that user to only read, update, insert or delete where their userid is.

我已经阅读了有关mysql触发器的一些内容,但没有找到对我有用的任何内容.

I have read some things on mysql triggers but have not found anything that will work for me.

我们有一个后端,其中包含数据并受用户标识限制.

We have a backend that has data in it and restricted by userid.

网站根据用户ID(select * from articles where userid=1)从该表中提取数据.现在,该代码可由用户修改.我想要一种从文章中选择*的方法,并且mysql仅针对该mysql用户生成具有userid=1的行.目标是让每个用户都有自己的mysql用户登录mysql数据库,这将限制为该用户ID的特定值.

The website pulls data from that table based in userid so select * from articles where userid=1. Right now, that code is modifiable by the user. I would like a way to go select * from articles and mysql only results rows that have userid=1 for that mysql user. The goal would be for every user to have their own mysql user login to the mysql database that would restrict to that specific value of userid that is theirs.

有什么想法吗?非常感谢!

Any thoughts? Thanks so much!

推荐答案

GoogleResult[0]具有此功能:

http://www.sqlmaestro.com/resources/all/row_level_security_mysql/

摘要

本文包含有关使用视图和触发器等MySQL功能在MySQL 5.0及更高版本中实现行级安全性的分步指南.

The article contains a step-by-step guide to implementation of row level security in MySQL 5.0 and higher using such MySQL features as views and triggers.

这篇关于mysql用户行级访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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