NOTE: The following methods work for both Ubuntu Lucid LTS and Debian Squeeze versions of TurnKey FileServer. AppArmor seems disabled by default in the TKL version of Ubuntu, so no changes to AppArmor are needed
To change default location (/var/lib/mysql) of mysql databases using datadir in my.cnf (preferred method):
- /etc/init.d/mysql stop
- cd /var/lib/mysql
- ls -l (to check which databases are present in folder)
- mkdir /srv/storage/mysqldata
- chown -R mysql:mysql /srv/storage/mysqldata
- IMPORTANT: *Only* the databases need to be copied over to new location (i.e. do not copy over ib* files etc); therefore if we have 2 databases in /var/lib/mysql called 'mysql' and 'phpmyadmin' then we do:
- 'cp -r mysql /srv/storage/mysqldata/' and 'cp -r phpmyadmin /srv/storage/mysqldata/'
- chown -R mysql:mysql /srv/storage/mysqldata/*
- in /etc/mysql/my.cnf, *only* the 'datadir' line needs to be changed to: datadir = /srv/storage/mysqldata
- /etc/mysql/debian.cnf file should not be touched
- /etc/init.d/mysql start
To change default location (/var/lib/mysql) of mysql databases using mount-bind (alternative method):
- /etc/init.d/mysql stop
- mv /var/lib/mysql /var/lib/mysql_original (backup first for safety)
- mkdir /srv/storage/mysqldata
- cp -R /var/lib/mysql_original/* /srv/storage/mysqldata/
- mkdir /var/lib/mysql
- mount -o bind /srv/storage/mysqldata /var/lib/mysql
- chown -R mysql:mysql /var/lib/mysql
- /etc/init.d/mysql start
No comments:
Post a Comment