No announcement yet.

How to Setup Disk Quotas For MySQL Database


Unconfigured Ad Widget

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Setup Disk Quotas For MySQL Database

    WordPress Hosting on SSD Servers
    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.

  • #2
    ASP.Net Hosting starts @ $3.18/Mo.
    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.



    Sign up for a News Letter Click here to sign up