I have run into a situation where the current MySQL setup outgrew the original partition scheme. Yeah that sux. You have no idea. so I had to move the location of the MySQL data store. Here is what I did.
stop MySQL… this will throw fits if you don’t.
/etc/init.d/mysql stop
Take note on heavily used servers that can take a while for the transactions to finish. Just keep that in mind.
Anyway now you need to copy the files to your new location
cp -a /var/lib/mysql /foo/mysqlstore
your permissions should be preserved but double check. It really doesn’t hurt.
ls -lah /foo/mysqlstore
Move the old mysql store to a new location (for saftey purposes, just rename the directory until you know this all works)
mv /var/lib/mysql /var/lib/mysql.good
I found a site that recommended making a symbolic link to the original location, and I thought it was a good idea. So I do that too. Make sure that user and group are set to mysql
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql
ln -s /foo/mysqlstore/ /var/lib/mysql.good/
Whoo hoo it is done now. Wait… we need to tell MySQL to look to the new location.
as always we make a backup of the file we are about to change.
cp -a /etc/mysql/my.cnf /etc/mysql/my.conf.good.YYYYMMDD
emacs or vi your conf file (use any thing you want that edits the file pico, gedit, magnetic chisel if you so desire)
vi /etc/mysql/my.cnf
Edit the following lines:
socket = /var/run/mysqld/mysqld.sock
and
datadir = /var/lib/mysql
to
socket = /foo/mysqlstore/mysqld.sock
and
datadir = /foo/mysqlstore
start up MySQL
/etc/init.d/mysql start
It should work and you can now have a martini. If you have to put off the martini for a few minutes because it won’t start. Read your logs. They will tell you what is wrong. Fix what is wrong and then since it didn’t work off the bat you get two martinis.