|
发表于 2005-5-8 13:26:32
|
显示全部楼层
How can I limit the size of MySQL databases?
Jan 28th, 2000 11:56
Benjamin Pflugmann, Nathan Wallace
Benjamin Pflugmann
MySQL has no built in method for doing db size limits, but since mysql
runs on your OS's file system, you might be able to specify disk limits
there.
You don't need to worry about this leaving your database in an
inconsistent state. AFAIK, MySQL should behave as in a "disk full"
condition, which will not leave an inconsitent state. The exact
behaviour is documented in the manual.
But you won't get an error, but MySQL will get "hanging" threads, even
up to the state where no new connections are accepted. This will
'heal' as soon as you make free space available.
If your OS supports group quotas, you can even set different limits for
each database user - as long as there is a corresponding system user
with an own group (like ftp1003):
So, change the group of the database directory in question to group
"ftp1003" (or whatever it is) and let the user id as it is (probably
root or mysql). Additionally set the set-group-id flag of the directory
(chmod +s), which will assure that new table files will inherit the
group.
Then set the group quota (you have to find out yourself how, I only
know, that it is possible), and you are done.
The quota will include all files of this group, so you might give the
user an additional group if you want to give him a different mysql
quota than quota for uploaded files.
The commands from above could look like (for database "test" on a Linux
system)
cd <where-your-mysql-database-is>
chgrp ftp1003 test
chmod g+s test |
|