Tips on migrating MySQL database to new server

Post Reply
jmcafee
Observer
Observer
Posts: 22
Joined: Fri Sep 08, 2017 5:01 am
Location: West Linn, Oregon
Station model: Davis Vantage Pro 2
Software: Meteohub
Contact:

Tips on migrating MySQL database to new server

Post by jmcafee » Sat Jun 02, 2018 2:05 am

I ran into unexpected roadblocks to data migration between servers that required much trial and error to overcome. The unanticipated problems mostly revolve around database tables with many records, and different versions of MySQL. I hope my experience can help anticipate and mitigate the frustration you could encounter.

My source database tables had over 600,000 records each hosted by MySQL 5.6x. The import servers included my own Centos 7, Ubuntu 14.4, and Ubuntu 18.4; and an online shared host. The Centos 7 runs MariaDB 5.6, and the online host runs MariaDB 10.1. This is what I encountered and methods to solve:
  • If your export and import servers are MySQL, the versions must be similar (such as, 5.6x); otherwise the importing server will complain about the different version (such as 5.6 -> 5.7). MySQL 5.6x is available only for Ubuntu 14.4; 18.4 binaries are maintained for only for 5.7 and higher. No problem with import servers running MariaDB 5 & 10, which is supposed to be compatible with all versions of MySQL.
  • Although you can export all tables at once into a single export file, I suggest that you export each table separately to better control the size of the exported file for reasons described below.
  • MySQL export would die from a timeout if more than about 220k rows were exported at a time. I exported 200k rows at a time using the "Custom" options and specifying the starting row and # of rows, SQL format. For the first chunk I selected the "Drop table" command so that a new table would be created with the first chunk (but do not select for the other chunks!).
  • MySQL export defaults to 50,000 queries (essentially attaching a massive number of rows to a single "Insert" statement), but this number may be too much for the import server to handle at once. In the export Custom options choose a query number of 1000.
  • Successfully created export files might still be too large for the input server to handle. To the rescue: https://www.ozerov.de/bigdump/, a php script that gracefully regulates the flood of inserts into the new database. This really works well, and I suggest that you give Alexsey a few dollars for saving you from a gigantic headache.

andyk1
Professional
Professional
Posts: 433
Joined: Tue Feb 27, 2018 10:56 pm
Location: OKLAHOMA, USA
Station model: Ecowitt WS90
Software: Meteobridge/GW2000B
Contact:

Re: Tips on migrating MySQL database to new server

Post by andyk1 » Mon Jun 11, 2018 7:24 am

Thanks for the info

Andy
Image

Post Reply