Site Fuse! programming, design, hosting, promotion and advertising tips for webmasters
Design    Programming    Hosting    Classifieds

Running MySQL from another partition (moving data dir)


Important: The following is a text only archive!
For full features; Go to Running MySQL from another partition (moving data dir)

posted by 2Guns Here're the steps to move your MySQL data dir to another partition or HDD.


Stop MySQL

Create MySQL and database directories;

mkdir /2ndpartition/mysql
mkdir /2ndpartition/mysql/dbname
Copy table files from your original database dir to the partition you're going to use;

cp -a /var/lib/mysql/dbname /2ndpartition/mysql/dbname
(verify data moved by checking home directory contents - VERY IMPORTANT)

Make backup directory just in case;
mv /var/lib/mysql/dbname /var/lib/mysql/dbname.bak

ln -s /2ndpartition/mysql/dbname /var/lib/mysql/dbname
change owner or /2ndpartition/mysql/dbname to mysql

Restart MySQL

Should work fine. I've done it a bunch of times without problem, and var partition should be cleared up.