Home » Topic » How to move mysql data directory from /var to another directory

How to move mysql data directory from /var to another directory

Right now I have the default mysql configuration, thats why my data folder is over the /var/ partition,and since this partition is keeping without free space. So you want to move mysql data directory from /var to another directory.

The easiest way would be moving /var/lib/mysql to any other partition that has enough disk space and create a symbolic link for /var/lib/mysql pointing to that new path. e.g Assuming you have enough space in /home and you want mysql data directory moved there:

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

2. Stop MySQL

/etc/init.d/mysql stop

3. 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
/etc/init.d/mysql start

4. Re-check monitor in WHM > Service Manager for MySQL and save the area

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry from last 7 years.

Leave a Reply

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

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud