Import Large SQL Files

I've been in the process of server migration over the past few days. It's been easy and I've experienced no down time thanks to Cloudflare and the fact that DNS propagation takes a while.

One of the hardest parts of migration wasn't the site files, it was the databases! I had exported all of the databases into 1 SQL file via phpMyAdmin, but it was too large for phpMyAdmin to import so I had to find a way to get everything back where it belonged! Thankfully, MySQL makes this simpler than I'd imagined.

To import a SQL file:

  1. Login to the server via SSH
  2. Login to mysql with: mysql -u USER -p'PASSWORD'where USER is your MySQL user and PASSWORD is your MySQL password.
  3. Type: source FILENAME.SQL where FILENAME.SQL is the path to the SQL file you wish to import
  4. Hit enter, and watch it import!