• Home
  • Free Stuff
  • About
  • Contact

WHM/CPanel : How to Move MySQL Data Folder

February 12, 2014

mysql-logoLast week, I checked WHM (Web Hosting Management) server which used by this blog,  Excellent website and  Vavai.com due to an error messages regarding failed WHM update. After a few checking, it seems that root partition only left a bit free space and one of the largest folder  is var/lib/mysql which contain a MySQL server databases. Before the partition getting lower and lower and would caused another problem, I decided to move the folder to another bigger partition.

The following are the processes which I have done to prevent further problem. Please note that while doing this setting, there will be a minimal down time (1-2 minutes). In this case, I prepare different partition on /dev/sdc1 which have approximately 100 GB free space and mounted to /srv/whm) :

  1. Go to WHM, choose Service Manager menu and uncheck on Monitoring MySQL option  then click save. It’s an important step to prevent MySQL services to being automatically restart by WHM service monitor
  2. SSH or Putty to WHM console and run the following command :
    mkdir -p /srv/backup/
    chmod 777 -R /srv/backup
    mysqldump --all-databases | gzip > /srv/backup/alldatabases.sql.gz
    rsync -av /var/lib/mysql /srv/whm/
    chown -R mysql:mysql /srv/whm/mysql
    /etc/init.d/mysql stop
    rsync -av --delete-after /var/lib/mysql /srv/whm/
    mv /var/lib/mysql /srv/backup
    ln -s /srv/whm/mysql /var/lib/mysql
    /etc/init.d/mysql start
  3. Back again to WHM, choose Service Manager and check on monitoring MySQL then save

On the above step, I choose to take a safe precaution, so I back up the data using rsync command before moving the data.  It would take longer steps but safer than the simple steps but  has risk of data loss. If you feel confident, you can ignore the rsync command and  just go through the instruction : Shutting down MySQL service, move the data into another folder, then make the symlink, and finally re-activate the MySQL services.

Actually, those instructions are should be applicable for non WHM MySQL server, for example, to move the mysql data on openSUSE / SLES server.

CPanelMovingMySQLSLESSUSE FamilyWHM
Share

Linux

Masim "Vavai" Sugianto
Traveller, Open Source Enthusiast & Book Lover. Works as Independent Worker & Self-Employer.

2 Comments


Michal Hrusecky
February 13, 2014 at 23:27
Reply

Just a suggestion: wouldn’t it be better instead of symlinking setting up datadir in my.cnf properly?



Masim "Vavai" Sugianto
February 14, 2014 at 04:00
Reply

Hi Michal,

Thank you for symlink suggestion. I would like to keep MySQL configuration as is and prevent the possibility of overwriting the configuration file while updating WHM/CPanel, CMIIW.



Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Recent Posts

    • Upgrading Zimbra 8.8.12 into 8.8.15 LTS
    • Docker Apps for Warming Up SMTP IP Address
    • Rsyslog Warning on Docker : rsyslogd: imklog: cannot open kernel log (/proc/kmsg)
    • Automatically Setting Timezone on Dockerfile
    • Create a Crontab Through a Script
    • Error debconf: unable to initialize frontend: Dialog
    • Custom SSL Certificate Deployment on vCenter Server 6.7
    • Commercial SSL Certificate Deployment on vSphere Host 6.7
    • VMware vSphere 6.7 Ebook (Indonesian)
    • Pursuing FIRE in Indonesia : Expenses and Living Cost



© Copyright LetsBlog Theme Demo - Theme by ThemeGoods