Published on: September 14, 2014 by George K.
Sometimes due to lack of Disk space in /var various activities such as logging gets affected and it may have severe impact on service and server uptime. In some cases, it is observed that default MySQL installation occupies large chunk of space in the /var partition due to the db data present in the default MySQL data directory /var/lib/mysql.
Here we are discussing the necessary steps to move mysql data directory location from /var/lib to /home without changing the configuration file. Of course the ideal way is to change the data directory variable in /etc/my.cnf. This is just a work around utilizing the property of soft links to avoid downtimes and application configuration changes.
1) Stop MySQL
root@server [/var/lib]# /etc/init.d/mysql stop
2) Go to WHM -> Service Manager -> Uncheck MYSQL service to disable it.
Uncheck Enabled and Monitor against mysql
3) Copy the entire mysql data directory ( I assume that this is a default installation, verify the configuration file /etc/my.cnf for verification) from /var/lib to /home by preserving the ownership, timestamps etc
root@server [/var/lib]# cp -pR mysql /home/
4) Move/Rename the mysql directory in /var/lib for the sake of backup
root@server [/var/lib]# mv mysql mysql_bak
5) Create Softlink in /var/lib to /home
root@server1 [/var/lib]# ln -s /home/mysql mysql
6) Restart MySQL
root@server [/var/lib]# /etc/init.d/mysql start
7) Enable Mysql service in WHM
Once the MySQL server is up, you may either delete or move the previous mysql directory from /var/lib to somewhere else to free space on /var partition.
Category : cPanel, Howtos, MySQL, Troubleshooting
Add new commentSIGN IN