How to quickly copy MySQL InnoDB database without using MySQL dump

I had a problem recently when I had to copy a pretty big InnoDB database from one server to another.

Doing import-export through MySQL dump was taking forever, so I found this easy way to do that.

  1. First of all, stop MySQL on both servers (service mysql stop)
  2. You need to copy several files in your MySQL DB folder. Mine was /var/lib/mysql/
  3. Locate the folder with the name of your database and copy that. I highly recommend rsync for copying files between two servers.
  4. Copy ibdata1, ib_logfile0, ib_logfile1, mysql_upgrade_info
  5. Start MySQL (service mysql start)

That’s it! Now you have your entire DB copied and it probably took 100x less time.

Please note that you must have the same architecture on both machines. I.e. if you have 32-bit on one server and 64-bit on another – you will have to use MySQL dump.

Leave a comment

Your email address will not be published. Required fields are marked *