limit database size

joma

Verified User
Joined
Jun 5, 2009
Messages
15
hello,

i know the space of account include the database and website documents,

i want to ask if it is possible create a feature to limit the size of database ?

for example,

a) admin can limit all the database to 50mb max only.

or

b) admin can design different database size as packages,
package-1 is 10MB,package-2 is 20MB,package-3 is 30MB,
and admin (or reseller) can assign certain or hosting account can have how many database package.



thank you
 
There is a way to do this, but this will be custom.
You can include database in the user quota, that could be a solution.
 
hello,
There is a way to do this, but this will be custom.

could you give me some hint about this?

You can include database in the user quota, that could be a solution.

do you mean i create another user account with the same size,
and create a database in it?


thank you
 
No. As MySQL keeps the Database files in /var/lib/mysql you will need to count that.
So it's possible to make a script in bash that count's the file size of users database.
Or you can make a script that connects to mysql and execute's :

SELECT table_schema "MySQL Databases", sum( data_length + index_length ) /1024 /1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema
LIMIT 0 , 30

Then you can read the information and execute another script that can prevent the user to update/insert/create information in the new database.
When the quota will go back to normal, you can enable everything back.
 
I (personally) don't know any way to limit DB size on MySQL server side. Probably my knowledges are not actual in this question any more. So you might want to google. The only solution I've ever found on this question is to remove (temporary) all permissions to write in DB from MySQL users if the account is over the disk limit. But I've never done, because its realisation is not that simple and can break many things on clients' side.

So while there is no built-in in MySQL limits, directadmin is not able to limit by itself.
 
Thank you Peter

An approach from the first link can be modified (at least you can give a try) the following way. Group quotas should be enabled on the partition with DBs files on the server, then one should do chgrp for every /path/to/mysql/data/dbname

The second link describes approach, which I was talking about.
 
Back
Top