WordPress Migration Woes: How I Fixed Database and File Transfer Issues

WordPress Migration Woes: How I Fixed Database and File Transfer Issues

Last Updated on March 3, 2025 by Mike Kipruto

Migrating a WordPress site should be straightforward—back up, transfer, restore, done. But in reality? It’s more like a tech obstacle course. I recently moved a WordPress site to a new server and hit every snag you can imagine: database hiccups, file transfer glitches, and domain woes. If you’ve ever stared at a MySQL error or wondered why your site’s still offline, this guide’s for you. Let’s break down the chaos—and how I fixed it.

The Migration Plan

TThe mission: relocate a WordPress site—files, database, and all—to a shiny new server. Here’s the playbook I started with:

  1. Backup everything – Zip the files and export the database.
  2. Move the files – Ship them to the new server via scp.
  3. Restore the database – Import the SQL dump into a fresh MySQL setup.
  4. Tie it together – Tweak WordPress settings and point the domain.

Simple on paper. In practice? Buckle up.


Hurdle 1: MySQL Connection Issues

First hurdle: MySQL wouldn’t connect on the new server. After running mysql_secure_installation, I got slapped with:

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Solution:

  • Checked MySQL status: systemctl status mysql (or mysqld depending on the system)
  • Ensured MySQL was running and listening on the right socket with sudo netstat -plnt
  • Restarted MySQL: sudo systemctl restart mysql
  • Finally, updated the MySQL root password and granted privileges to avoid authentication issues.

Hurdle 2: File Transfer Problems

Transferring WordPress files over SSH using scp seemed straightforward, but I wanted to ensure a clean move. To avoid permission issues, I opted to zip the files before transfer:

zip -r wordpress_files.zip /path/to/wordpressscp wordpress_files.zip user@1.1.1.2:/var/www/html/

Once on the new server:

unzip wordpress_files.zip -d /var/www/html/

This approach minimized transfer errors and preserved file permissions.

For those new to scp, it’s a secure way to copy files between servers. The syntax is:

scp [options] source_file user@destination_host:/path/to/destination

You can read more about scp here: SCP Documentation


Hurdle 3: Restoring the WordPress Database

The database was another beast to tackle. Since my backup consisted of .frm and .ibd files, a direct import wouldn’t work. Instead, I dumped the SQL from the original server:

mysqldump -u root -p wordpress_db > wordpress_db.sqlscp wordpress_db.sql user@1.1.1.2:/var/www/html/

On the new server, I created a fresh database and imported the dump:

mysql -u root -p wordpress_db < /var/www/html/wordpress_db.sql

This ensured all tables were correctly restored and ready for WordPress to use. If you’re unfamiliar with mysqldump, it’s a tool for exporting MySQL databases. More details can be found in the MySQL Documentation.


Hurdle 4: Updating WordPress Configuration

After restoring the database, I had to ensure WordPress could connect to it. This meant updating the wp-config.php file:

/** Database settings **/define('DB_NAME', 'wordpress_db');define('DB_USER', 'root');define('DB_PASSWORD', 'your-secure-password');define('DB_HOST', 'localhost');

To avoid permission issues, I ran:

sudo chown -R www-data:www-data /var/www/html/

Final Step: Pointing to the Domain

With everything in place, the last step was to point the domain to the new server. I updated my DNS records, ensuring the A record pointed to the new server’s IP address (1.1.1.2). To ensure proper SSL support, I reissued certificates using Let’s Encrypt:

sudo certbot --nginx -d example.com -d www.example.com

After clearing my browser cache and DNS propagation delays, my site was back up!

If you’re dealing with domain and DNS changes, this Cloudflare Guide provides helpful insights on managing DNS settings.


Lessons from the Trenches

WordPress migrations are a test of patience, but they’re manageable with the right moves. Here’s what stuck with me:

  • Backups are non-negotiable. Always have a safety net.
  • Zip before you ship. Compression makes scp smoother.
  • Test MySQL first. No point importing to a dead server.
  • Config and permissions matter. Nail wp-config.php and ownership early.
  • DNS and SSL seal the deal. Don’t skip the final polish.

Whether you’re a sysadmin, dev, or DIY webmaster, you’ll hit these bumps eventually. Tackle them step-by-step, and you’ll come out on top. My site’s now humming on its new home—proof that even a rocky migration can end in victory. 🚀

20