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.