We do support Round the Clock 24 x 7 x 365 (+91) 883 012 3924
 

How to Safely Change the Location of MySQL Data Directory on cPanel/WHM CloudLinux Servers

How to Safely Change the Location of MySQL Data Directory on cPanel/WHM CloudLinux Servers

1. Make a full mysqldump file

# mysqldump --opt -uroot -proot_password > /tmp/mysqldump

2. Uncheck monitor in WHM > Service Manager for Mysql and save the area

3. Stop MySQL service

# /etc/init.d/mysql stop

4. Ensure that the following settings are present

check file /etc/systemd/system/mariadb.service.d/homedir.conf
[Service]
ProtectHome=false
ProtectSystem=off

5. Make the directory for MySQL in /home, move it and symlink it:

# mkdir /home/var_mysql
# mv /var/lib/mysql /home/var_mysql
# chown -R mysql:mysql /home/var_mysql/mysql
# ln -s /home/var_mysql/mysql /var/lib/mysql

6. Remount CageFS system-wide:

# cagefsctl --remount-all

7. Start MySQL:

# /etc/init.d/mysql start

1 Comments

Leave a Reply

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