How To Migrate MySQL To A New Volume On CentOS

Stop MySQL and move the existing database files to the EBS volume.
1 2 3 |
service mysqld stop mkdir /data/mysql mv /var/lib/mysql/ /data/mysql/lib/ |
Use the bind option to the mount command in the /etc/fstab file to direct MySQL to the correct files, then restart:
1 2 3 4 |
mkdir /var/lib/mysql echo "/data/mysql/lib /var/lib/mysql none bind" | tee -a /etc/fstab mount /var/lib/mysql service mysqld start |