Change mysql database directory

Kailash1

Well-Known Member
Nov 27, 2006
259
6
168
cPanel Access Level
Root Administrator
Twitter
Hi,

I have stored Mysql database in /var/lib/mysql location and now /var is about to reach its allocated space. Is there any way I can change the location and move the existing Mysql databases to new location?

Thanks,

Kailash
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator

Marty

Well-Known Member
Oct 10, 2001
629
1
318
cd /var/lib

service chkservd stop

service mysql stop

mv mysql /home

ln -s /home/mysql mysql

service mysql start

service chkservd start

That is the way I do it. Use at your own risk. I think I have ln -s command correct.
 
  • Like
Reactions: jugo

Marty

Well-Known Member
Oct 10, 2001
629
1
318
Will it create any problem taking cPnel backup (including MySQL databases) after changing the location of MySQL databases.

Thanks,

Kailash
No, the backups will follow the symlink, so there is no problem at all.