Fri, 02 Jul 2010
Keywords: copy mysql database db directory files disk partition machine
I wanted to copy a MySQL database on a disk that used to be attached to a Ubuntu machine that died, to its replacement. It turns out not to be too difficult.
# stop mysql # mv /var/lib/mysql /var/lib/mysql.orig # cp -a /media/old-disk/var/lib/mysql /var/lib # chown -R mysql:mysql /var/lib/mysql
There were a couple of files in /var/lib/mysql that were owned by root - mysql_upgrade_info and debian-5.1.flag in my case. Change them back to being owned by root.
# start mysql
I actually had to reboot since something hung on restarting mysql. I have no idea why. Logs can be found in /var/log/mysql/error.log if required.