如何设计一个多租户的mysql数据库

2023-05-24数据库问题
10

本文介绍了如何设计一个多租户的mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

假设我需要设计一个数据库,该数据库将托管多个公司的数据.现在出于安全和管理目的,我需要确保不同公司的数据被正确隔离,但我也不想启动 10 个 mysql 进程来在 10 台不同的服务器上托管 10 家公司的数据.使用 mysql 数据库执行此操作的最佳方法是什么.

Let us say I need to design a database which will host data for multiple companies. Now for security and admin purposes I need to make sure that the data for different companies is properly isolated but I also do not want to start 10 mysql processes for hosting the data for 10 companies on 10 different servers. What are the best ways to do this with the mysql database.

推荐答案

多租户数据库有多种方法.为了便于讨论,它们通常分为三类.

There are several approaches to multi-tenant databases. For discussion, they're usually broken into three categories.

  • 每个租户一个数据库.
  • 共享数据库,每个架构一个租户.
  • 共享数据库,共享架构.租户标识符(租户键)将每一行与正确的租户相关联.

MSDN 有一篇关于 每种设计的优缺点,以及实现示例.

MSDN has a good article on the pros and cons of each design, and examples of implementations.

<小时>微软显然已经删除了我提到的页面,但它们在 archive.org 上.链接已更改为指向那里.


Microsoft has apparently taken down the pages I referred to, but they are on on archive.org. Links have been changed to point there.

作为参考,这是第二篇文章的原始链接

这篇关于如何设计一个多租户的mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14