How To Move MySQL Data Directory On A Separate Partition

Prerequisite: A free partition that will serve as a dedicated MySQL partition.

Note: These instructions assume that the partition you wish to mount is /dev/sdc1

  1. Backup all MySQL databases
    Code:
    mysqldump --opt --all-databases | gzip > /home/alldatabases.sql.gz
  2. Stop tailwatchd and the mysql (tailwatchd monitors services, so disable it to prevent it from prematurely restarting mysql)
    Code:
    /scripts/restartsrv_tailwatchd --stop
    /scripts/restartsrv_mysql --stop
  3. Backup the MySQL data directory in case something goes awry
    Code:
    mv /var/lib/mysql /var/lib/mysql.backup
  4. Create the new mount point
    Code:
    mkdir /var/lib/mysql
  5. Configure /etc/fstab so that the new partition is mounted when the server boots (adjust values as necessary)
    Code:
    echo "/dev/sdc1     /var/lib/mysql     ext3     defaults,usrquota    0 1" >> /etc/fstab
  6. Mount the new partition. The following command will mount everything in /etc/fstab:
    Code:
    mount -a
  7. Change the ownership of the mount point so that it is accessible to the user “mysql”
    Code:
    chown mysql:mysql /var/lib/mysql
  8. Ensure that the permissions of the mount point are correct
    Code:
    chmod 711 /var/lib/mysql
  9. Start mysql and tailwatchd
    Code:
    /scripts/restartsrv_mysql --start
    /scripts/restartsrv_tailwatchd --start
  10. Ensure that the MySQL data directory is mounted correctly:
    Code:
    mount |grep /var/lib/mysql
  11. You should see a line that looks like this:
    /dev/sdc1 on /var/lib/mysql type ext3 (rw,usrquota)

Source