top the mysql server:
stop mysql
Create the new directory:
mkdir /array2/mysql
Copy over ONLY the database folders:
cp -R /var/lib/mysql/mysql /array2/mysql
cp -R /var/lib/mysql/users /array2/mysql
Backup the my.cnf file:
cp /etc/mysql/my.cnf /root/my.cnf.backup
Edit the my.cnf file:
nano /etc/mysql/my.cnf
Change all mentions of the old datadir and socket to your new location
Mine became:
datadir=/array2/mysql
socket=/array2/mysql/mysql.sock
Update the directory permissions:
chown -R mysql:mysql /array2/mysql
Rename the old directory:
mv /var/lib/mysql /var/lib/mysql-old
Create a symlink, just in case:
ln -s /array2/mysql /var/lib/mysql
Then update the AppArmor file:
nano /etc/apparmor.d/usr.sbin.mysqld
Comment out the old references to /var/lib/mysql and add:
/array2/mysql/ r,
/array2/mysql/** rwk,
Reload the apparmor profiles
sudo /etc/init.d/apparmor reload
Then start mysql:
start mysql
stop mysql
Create the new directory:
mkdir /array2/mysql
Copy over ONLY the database folders:
cp -R /var/lib/mysql/mysql /array2/mysql
cp -R /var/lib/mysql/users /array2/mysql
Backup the my.cnf file:
cp /etc/mysql/my.cnf /root/my.cnf.backup
Edit the my.cnf file:
nano /etc/mysql/my.cnf
Change all mentions of the old datadir and socket to your new location
Mine became:
datadir=/array2/mysql
socket=/array2/mysql/mysql.sock
Update the directory permissions:
chown -R mysql:mysql /array2/mysql
Rename the old directory:
mv /var/lib/mysql /var/lib/mysql-old
Create a symlink, just in case:
ln -s /array2/mysql /var/lib/mysql
Then update the AppArmor file:
nano /etc/apparmor.d/usr.sbin.mysqld
Comment out the old references to /var/lib/mysql and add:
/array2/mysql/ r,
/array2/mysql/** rwk,
Reload the apparmor profiles
sudo /etc/init.d/apparmor reload
Then start mysql:
start mysql
No comments:
Post a Comment