There are a lot of answers on Google about moving a MySQL datadir, but the gist of it on linux is:
- Be logged into the Supervisor as the root user
- Stop the Supervisor service:
/etc/init.d/supervisor stop
- Stop the mysql server:
/etc/init.d/mysqld stop
- Copy the current datadir over to the new location ensuring that you preserve ownership and permissions:
cp -rP /var/lib/mysql /newpath/mysql
- Rename the current datadir so that it won't be found by mistake, but leave it in place so you have a fallback plan:
mv /varl/lib/mysql /var/lib/mysql.MOVED
- Edit the /etc/my.cnf, copy the
datadir
line, comment out the original as a backup (part 2 of the fallback plan), and edit the uncommented line to point to the new location - Start the mysql server:
/etc/init.d/mysqld start
- Check that the new datadir is the one being used:
mysql -u root -e "SHOW variables like 'datadir'"
+---------------+-----------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------+
| datadir | /usr/local/MySQL-5.1.44-MACOSX-Universal/var/ |
+---------------+-----------------------------------------------+
If it looks good, start the Supervisor service:
/etc/init.d/supervisor start