Linux: Move mysql data files to new location

Want to change the default mysql data_dir  (/var/lib/mysql) to new location (new partition, new disk ?)

Steps to do:
1. stop mysql ( /etc/init.d/mysql stop)
2. copy your mysql data directory to new location ( mv /var/lib/mysql/ /newlocation/mysql/)
3. chown -R mysql:mysql /newlocation/mysql
4. edit file /etc/mysql/my.inf ( change data_dir location)
5. edit file /etc/apparmod.d/usr.sbin.mysqld (change /var/lib/mysql to your new location)
6. start mysql (/etc/init.d/mysql start)

Leave a Reply