[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] How can I quota spaces of MySQL database.



Hi Piya,

>      Anybody know please show me the way "How to quota spaces usage of
MySQL
> database".

This has been discussed a few months ago, but I couldn't even find it in the
list archive myself.

Short version: let's say the Linux user you'd like the quota on is called
"user" and the Linux MySQL user is "mysql" (as it should be). Su to root
("su -") and head on over to /var/lib/mysql (if the MySQL pkg keeps the
directory structure intact). If the database needs to be created, first
create the directory it will be in (mkdir dbname) or have a directory
"dbname" ready in user's homedir. Then, symlink that dir (IIRC, "ln -s
dbname /home/sites/whatever/user/dbname"; do a "man ln" before you might
screw up). Okay, emtpy database in place.

Next, head on over to /home/sites/whatever/user. Do a "chown user.mysql
dbname" and make sure both the user "user" and the user "mysql" can read,
write and 'execute' this dir (ie, cd into it): "chmod 770 dbname". If the
database existed previously, chmod the files in that dir to 770 aswell.

[Question to the group, just thought of this now: wouldn't it be better if
the directory "dbname" was chmod'ed 070, 470 or 570 to disallow user "user"
to screw stuff up through ftp or a shell?]

Now, the database "dbname" falls under the disk quota of user "user".

Sidenote: I haven't fully tested it yet, but my belief is that when you
access this database "dbname" as the MySQL root user and make changes to it,
the files in /home/sites/whatever/user/dbname will be chowned back to
mysql.mysql and your quota thingie is gone.

Try this on a testdatabase first, as I typed the stuff above from the top of
my mind.

Hope this works for you... Nico