How, with a mounted disk image, can I migrate a MySQL database to a new server?

One Ubuntu EC2 VPS is fried after an upgrade that went awry.

I don’t have the server live, but I have its disk mounted on another (Ubuntu EC2) VPS.

How can I migrate the contents of a database on the mounted filesystem so that I can load it on another machine?

I’ve used tar and sftp to move stuff in files and directories I’ve made. I don’t know what files would need to be copied to migrate MySQL, and I’ve gotten the impression that migrating a database appropriately means using database facilities to dump from one machine, then transferring the file to another machine, and then using database facilities to install on another machine: not simply cp.


It’s generally safe to copy the files, so long as MySQL is not running. This doesn’t mean that you won’t have to repair them later, especially if MySQL had previously crashed.

You’ll find them in the specified datadir in MySQL’s config; the default is usually /var/lib/mysql.

Source : Link , Question Author : Christos Hayward , Answer Author : Michael Hampton

Leave a Comment