How to Setup Disk Quotas For MySQL Database

Collapse

Unconfigured Ad Widget

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ryan
    Member
    • Jun 2008
    • 96

    How to Setup Disk Quotas For MySQL Database

    How to Setup Disk Quotas For MySQL Database

    MySQL server has no support for preventing disk from getting filled up. You need to depend upon external configurations. Let us see how to use standard Linux disk quota to limit user database size.

    Suppose you have a user ryan on the system as well as on MySQL. Now how do you limit space for ryan?
    1) Create a separate directory for databases in ryan's home say /home/ryan/dbs with ownership mysql:ryan and permissions 3755:

    # mkdir /home/ryan/dbs && chown mysql:ryan /home/ryan/dbs && chmod 3755 /home/ryan/dbs

    2) Now move all ryan's databases from /var/lib/mysql to /home/ryan/dbs

    # mkdir /root/backup
    # cp -avr /var/lib/mysql/* root/backup
    # mv /var/lib/mysql/database-name /home/ryan/dbs/
    # chown -Rf mysql:ryan /home/ryan
    # chmod -Rf 3755 /home/ryan
    # ln -s /var/lib/mysql/database-name /home/ryan/dbs/database-name -v

    Finally, restart mysqld. If mysqld starts with OK status, then its working else it isn't:

    # /etc/init.d/mysqld restart

    Always take the back up of your database before using these steps.
  • kilter
    Member
    • Oct 2009
    • 79

    #2
    Re: How to Setup Disk Quotas For MySQL Database

    well, this is an interesting idea, however, I see a few reasons this solution would be inconvenient in a cpanel environment.

    First, you'd have to manually do this everytime a user created a database. If you have hundreds (or thousands) of hosting clients, this will consume much of your time.

    Secondly, putting this into the users homedir is problematic... if the user has shell or ftp access to the root of their homedir, then they're likely to not understand what this is, they might overwrite or delete or otherwise corrupt their database, which would lead to support issues. It also might be a security hole, I'm not positive of this, but I imagine it might allow them to more easily exploit any potential holes in mysql.

    In reality, it would be trivial in the grand scheme of things for cpanel to solve this problem.
    Last edited by admin; 08-18-2015, 06:03 AM.

    Comment

    Working...
    X