Physically migrate MySQL without a dump

Here is what you can do:

  • Old DB Server : 10.1.2.30
  • New DB Server : 10.1.2.40

STEP 01) On the Old Server, service mysql stop

STEP 02) On the Old Server, rsync -av --progress /var/lib/mysql [email protected]:/var/lib/mysql

STEP 03) On the New Server, chown -R mysql:mysql /var/lib/mysql

STEP 04) On the New Server, service mysql start

Make sure /var/lib/mysql on the New Server is on a much bigger disk mount


You can also migrate it on-the-fly to another server, sending data through pipes and SSH. It's useful if the target host have a different MySQL version, for example.

I just wrote a blog post explaining how I did it:

http://blog.techutils.space/2016/02/on-fly-database-migration-between-two.html

There is an explanation there, but if you don't care, just run something like below.

Target host:

nc -l 3456 | \
  gunzip | \
  pv | \
  mysql -u tdb_user -ptdb_pass targetdatabase

Source host:

mysqldump -u sdb_user -psdb_pass sourcedatabase | \
  pv | \
  gzip | \
  ssh sshuser@targethost nc 127.0.0.1 3456