A
A
Anton Piskunov2011-09-15 09:19:36
MySQL
Anton Piskunov, 2011-09-15 09:19:36

Calculate used space by databases

Such a situation: there are quotas for /home/%username% and everything works fine, the user cannot fill the entire disk with his data.

But this quota does not work on MySQL databases that are stored in /var/lib/mysql. Accordingly, the user can put a gigabyte base on the server.

How can this problem be solved? How, for example, to calculate the space occupied by user databases? Or How can they be moved to /home/%username%?

PS
/home/%username% - chroot with your environment.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cat_crash, 2011-09-15
@cat_crash

It’s not a panacea, but what came to mind is to put the database files in / home /% username% and make symlinks to them in / var / lib / mysql
BUT you should think about what will happen to the database files when they run into a quota and the system will not give write more. This can happen quite quickly, as deleting rows does NOT delete data by default.

V
Vitaly Peretyatko, 2011-09-15
@viperet

The article www.cyberciti.biz/tips/linux-unix-setting-up-mysql-database-quotas.html describes practically what cat_crash suggested above, I'm really afraid that when the database hits the quota, it might break ... So there are links in the article to other solutions to this problem. The simplest option is to call a script by cron that counts how much space the user's databases occupy and if the volume exceeds the threshold, it takes away the user's rights to CREATE and INSERT for his database, when the volume falls below the threshold, the rights are returned.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question