[英]One large MySQL database for several clients
NB This is not another "One large DB or several small DBs" question. 注意:这不是另一个“一个大数据库或几个小数据库”的问题。
Using one large MySQL database for several clients (same structure, etc), with a user
column to separate the clients, is it possible limit the table access for the user with the matching user
column`? 使用一个大的MySQL数据库为多个客户端(相同的结构,等等),与user
列到客户分开,是否有可能限制,以匹配用户表的访问user
column`?
I'm not too familiar with Microsoft's SQL Server, but I read something about "multi-tenant data architecture" that seemed to offer this. 我对Microsoft的SQL Server不太熟悉,但是我读到一些有关“多租户数据体系结构”的东西,似乎提供了这一点。
Does MySQL have something similar? MySQL有类似的东西吗?
I would recommend against having 1 large DB for all your clients for multiple reasons: 由于多种原因,我建议不要为所有客户使用1个大型数据库:
A better mult-tenant archticture you want to have is: 您想要拥有一个更好的多租户架构:
Here's a great article titled " High Availability, Load Balancing, and Replication ," which will give you a great primer into building a robust multi-tenant system. 这是一篇很棒的文章,标题为“ 高可用性,负载平衡和复制 ”,它将为您构建强大的多租户系统奠定基础。 I would also recommend reading the articles on High Scalability 我还建议阅读有关高可伸缩性的文章
Please let me know if you have any questions! 请让我知道,如果你有任何问题!
MySQL has table-level and column-level privileges, but not row-level privileges. MySQL具有表级和列级特权,但没有行级特权。
The closest thing would be to define a VIEW through which a user accesses the table. 最接近的事情是定义一个VIEW,用户可以通过该VIEW访问表。 The view has privilege to access to the base table, and each user has privileges to access the view. 该视图具有访问基表的特权,每个用户都有访问该视图的特权。
Define the view to restrict access to the current user. 定义视图以限制对当前用户的访问。
mysql> create table base (user varchar(16), x int);
mysql> insert into base values ('root@localhost', 123), ('bill@localhost', 456);
mysql> create view v as select * from base where user = USER() with check option;
mysql> select * from v;
+----------------+------+
| user | x |
+----------------+------+
| root@localhost | 123 |
+----------------+------+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.