mysql 限制 库 大小_如何限制单个MySQL数据库的存储大小

bd96500e110b49cbb3cd949968f18be7.png

I want to be able to place limits on the storage size an individual MySQL database (for example 2GB per database). Was this able to be done? I'm unable to a find specific MySQL configuration that allows this.

Specifically I want to be able to do this on AWS RDS Instance - so any knowledge related to this would be helpful too.

Any help or guidance wether this could be done would be appreciated.

解决方案

This question was asked almost 10 years ago: MySQL schema size

I won't close your question as a duplicate because it has been long enough that it deserves a fresh answer.

Nothing has changed. There is no option for MySQL to define a cap on the size of an individual database.

You can make a max size for the system tablespace, and all your tables and schemas will fill this if you set innodb_file_per_table=0. You can configure the max size in your my.cnf this way:

innodb_data_file_path=ibdata1:12M:autoextend:max:1G

That's just an example, it means the ibdata1 file is initially created at 12MB, it grows as needed, but will not grow larger than 1GB. See https://dev.mysql.com/doc/refman/8.0/en/innodb-init-startup-configuration.html for more information.

Even with the potential limit on the system tablespace, this doesn't give you control over how much space each schema can use. They all use the same tablespace.

If you use innodb_file_per_table=1, each table is stored in its own tablespace file. There is no option for defining the size of a table-specific tablespace.

Since MySQL 5.7, you can also create a General Tablespace, and assign multiple tables to it. For example, you could choose to put all tables for a specific schema into one general tablespace. But this also has no syntax for defining a size limit of a general tablespace.

I've seen some solutions on the net to revoke insert/update privileges on a schema if it exceeds its size limit. But this is not enforced by MySQL, it's an external solution.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值