How to Migrate a WordPress Site Manually (cPanel, phpMyAdmin and Terminal)

11 min read

Share
Two servers with an arrow moving files and a database between them

To migrate a WordPress site manually, you copy two things to the new place: the files and the database. Then you connect them in wp-config.php and update the site's address in the database.

This is the method I use every time I move a site. A lot of my work is building a design on a subdomain or a temporary domain, then moving it to the client's real domain, sometimes on the same hosting, sometimes on another. It takes 20 to 60 minutes and needs no migration plugin.

In my experience the files are never the problem. The trouble comes from the database steps: the table prefix, the database password and the site URL. When those are skipped, the site shows errors after the move. So this guide spends most of its time on them.

Quick overview: the steps to migrate WordPress manually

  1. Back up the old site: files and database.
  2. Install WordPress on the new domain, so it has a fresh database and wp-config.php.
  3. Upload the old wp-content folder over the new install. The new install already has everything else.
  4. Empty the new database and import the old one.
  5. Match the table prefix in wp-config.php.
  6. Update the site URL in the wp_options table, and old links in the content if the domain changed.
  7. Test, then point the domain to the new host.

What do you need before you start?

  • cPanel (or a similar panel) on both the old and new hosting, with File Manager and phpMyAdmin;
  • FTP or SFTP access, with FileZilla or WinSCP, for big sites;
  • Terminal or SSH access on the new hosting, only for very large databases;
  • your WordPress admin login, and access to the domain's DNS settings.

Step 1: How to back up the WordPress site

With Softaculous (the easiest way)

If the site was installed with Softaculous in cPanel:

  1. Open Softaculous Apps Installer and go to All Installations.
  2. Click the Backup icon next to the site, tick both files and database, and start the backup.
  3. When it finishes, go to Backups and Restore and download the backup file.

The backup is an archive with all the files, plus the database as a .sql file inside it.

No Softaculous? Back up by hand

If your host has no Softaculous or backup tool, you only need two things:

  • The wp-content folder: in File Manager, open the site's folder (usually public_html), right-click wp-content, Compress it to a .zip and download it. For big sites, download the folder by FTP instead.
  • The database: open phpMyAdmin, click the site's database on the left, go to Export, choose Quick and SQL, and click Export. You get a .sql file.

Not sure which database belongs to the site? Open wp-config.php and look at the DB_NAME line.

Another way: the All-in-One WP Migration plugin

If you'd rather not touch phpMyAdmin at all, the free All-in-One WP Migration plugin can move the site for you:

  1. On the old site, install the plugin and go to All-in-One WP Migration > Export. Choose File and download the .wpress file.
  2. On the new domain, install WordPress, then install the same plugin.
  3. Go to Import, upload the .wpress file and confirm. The plugin replaces the files and the database, and changes the URLs for you.
  4. Log in with the old site's username and password, then go to Settings > Permalinks and click Save Changes.

The free version has an upload size limit, so it suits small and medium sites. For a large site, or when the import gets stuck, use the manual method in this guide.

Step 2: Install WordPress on the new domain

On the new hosting, add your domain (or use the main domain), then install WordPress on it with Softaculous or the host's one-click installer. Leave the default settings. You will replace everything anyway.

After the install, open the new site's wp-config.php and note these lines. They belong to the new database, and you need them later:

define( 'DB_NAME', 'newuser_wp123' );
define( 'DB_USER', 'newuser_wp123' );
define( 'DB_PASSWORD', '...' );
$table_prefix = 'wpab_';

Step 3: How to upload the WordPress files to the new hosting

You don't need to upload the whole site. The fresh install already has wp-admin, wp-includes and a working wp-config.php. Everything that makes the site yours is in one folder: wp-content. It holds your themes, plugins and uploads (all images and media).

  1. From your backup, take the wp-content folder and compress it to a .zip.
  2. Upload it to the new site's folder with File Manager or FTP. That's public_html for the main domain, or the addon domain's own folder.
  3. Delete or rename the new install's own wp-content, then Extract your zip in its place.

That's it. Don't replace wp-admin, wp-includes or wp-config.php.

If the old site had files of its own in the root folder, such as a custom .htaccess, robots.txt or a Google verification file, copy those across too.

Step 4: How to replace the database in phpMyAdmin

The new database has the empty tables of the fresh install. Remove them, then import the old ones.

Drop the tables of the new install

  1. In phpMyAdmin, click the new site's database on the left (the DB_NAME from step 2). Make sure it's the right one.
  2. On the Structure tab, tick Check all.
  3. From With selected, choose Drop and confirm.

Drop the tables, not the database itself. The database, its user and the permissions stay in place.

Import the old database

  1. With the same database selected, go to Import.
  2. Choose your .sql file and click Import.

phpMyAdmin shows the maximum upload size on the Import page. If your file is bigger, compress it first. phpMyAdmin accepts zip, gzip and bzip2, and the name must keep .sql before the extension, like backup.sql.zip or backup.sql.gz. SQL text compresses very well, often to a tenth of the size.

If it's still too big, or the import times out, use the terminal method below.

How to import a large SQL file with the terminal

When phpMyAdmin gives up, this is what I use. It's the fastest way for big databases: a file of hundreds of megabytes imports in one go, without upload limits.

  1. Upload the .sql file to your home folder, outside public_html, so nobody can download it from the web.
  2. In cPanel, open Terminal (under Advanced). Not there? Ask your host to enable SSH, or connect with an SSH client.
  3. Run this command, with your own database user and name:
mysql -u newuser_wp123 -p newuser_wp123 < backup.sql
  1. It asks for the password: paste the database password and press Enter. Nothing appears while you type, which is normal.

The first newuser_wp123 is the database user, the second is the database name. For a gzip file, use gunzip < backup.sql.gz | mysql -u USER -p DBNAME instead.

Where is the database password?

It's in the new site's wp-config.php, on the DB_PASSWORD line.

If it isn't there, or doesn't work, reset it:

  1. In cPanel, open MySQL Databases (or Manage My Databases).
  2. Under Current Users, click Change Password for the database user, and set a new strong password. A password generator is handy here.
  3. Put the same password in wp-config.php on the DB_PASSWORD line.

Run the import again, and it finishes in one step.

Step 5: Check the table prefix in wp-config.php

This is the step I see missed most often. After the import, look at the table names in phpMyAdmin. If they start with wp_, like wp_options, the prefix is wp_. If they start with something else, like wpxy_options, the prefix is wpxy_.

The prefix in wp-config.php must be the same:

$table_prefix = 'wpxy_';

If they don't match, WordPress can't find the tables and starts the installation screen ("Welcome to WordPress"), or shows a database error. Fix the one line and reload.

Check the other database lines in the same file too. DB_NAME, DB_USER and DB_PASSWORD must be the new database's details, including any password you just reset.

The Diff Checker helps if you're unsure what's different between the old and new wp-config.php. Paste both and it highlights the lines that changed.

Step 6: How to change the site URL in the database

The database still holds the old address. If the domain is the same, skip this step. If you moved to a new domain, from a subdomain like dev.example.com, or from http to https, you must update it.

Update siteurl and home in wp_options

  1. In phpMyAdmin, open the wp_options table (with your prefix, like wpxy_options).
  2. Find the rows siteurl and home. They're usually on the first page.
  3. Double-click the option_value field of each, type the new address, like https://example.com, and press Enter.

Use the full address with https:// and no slash at the end. Both rows should normally be the same.

Replace old links inside your content

siteurl and home only change the site's address. Your pages, menus, images and builder settings still contain links to the old domain. Replace those with:

  • the Better Search Replace plugin: search for the old domain, replace with the new one, and run a dry run first;
  • WP-CLI, if your host has it: wp search-replace 'old-site.com' 'example.com' --skip-columns=guid;
  • Elementor: also use Elementor > Tools > Replace URL, then regenerate CSS.

What if you forgot the admin password?

If the old admin login doesn't work on the new site:

  1. In phpMyAdmin, open the wp_users table and click Edit on your user.
  2. In the user_pass field, type a new password, choose MD5 in the Function dropdown, and click Go.
  3. Log in with the new password. WordPress upgrades the hash to a stronger one automatically.

How to migrate WordPress on the same hosting

Moving a site to another domain or subdomain on the same hosting account, for example from a dev subdomain to the main domain, is easier. Nothing needs downloading.

  1. Install WordPress on the target domain with Softaculous. This gives it its own database and wp-config.php.
  2. In File Manager, open the old site's folder and Copy its wp-content folder to the new domain's folder, replacing the new install's wp-content. Use Copy, not Move, so the old site keeps working until you're done. Nothing else needs copying.
  3. In phpMyAdmin, export the old site's database. Then select the new database, drop its tables and import, as in step 4. For big files, use the terminal method.
  4. Match the table prefix in the new wp-config.php (step 5).
  5. Change siteurl and home, and replace old links in the content (step 6).

Step 7: Test, then switch the domain

  1. Log in at example.com/wp-admin. The fresh install is usually a newer WordPress version than the old site, so you may see Database Update Required. Click Update WordPress Database. It takes a few seconds.
  2. Go to Settings > Permalinks and click Save Changes once. This rebuilds the .htaccess rules, so pages don't show 404 errors.
  3. Clear any caching plugin and the host's cache.
  4. Open the home page, a few posts, a page with images and the contact form, in a private window.

If you're moving hosts with the same domain, change the domain's nameservers or A record to the new host. DNS changes can take a few hours. Then make sure SSL works: in cPanel, run SSL/TLS Status (AutoSSL) for the domain.

Common errors after migrating WordPress

ProblemLikely causeFix
"Error establishing a database connection"Wrong DB_NAME, DB_USER or DB_PASSWORDCopy the new values into wp-config.php, or reset the password
The WordPress install screen appearsTable prefix doesn't matchFix $table_prefix (step 5)
Site redirects to the old domainsiteurl and home still oldUpdate them in wp_options (step 6)
Pages give 404, home page worksPermalink rules missingSettings > Permalinks > Save Changes
Images missing or styles brokenOld URLs in content, or http vs httpsSearch and replace the old domain
"There has been a critical error"Plugin or PHP version difference on the new hostSee how to fix the critical error
Import stops or times outFile too big for phpMyAdminCompress it, or use the terminal

Frequently asked questions

Can I migrate WordPress without a plugin?

Yes. A manual migration only needs file access and phpMyAdmin. It works for sites of any size, unlike free plugin versions that often limit the file size.

Will migrating WordPress affect my SEO?

Not if the URLs stay the same and the site is down only briefly. If you change domains, add 301 redirects from the old domain to the new one, and use Change of Address in Google Search Console.

Do I need to install WordPress before uploading the files?

It isn't required, but it's easier. Without it, you create the database and user by hand in MySQL Databases, give the user All Privileges on the database, and enter the details in wp-config.php yourself.

Should I drop the tables or the whole database?

Drop the tables. If you drop the whole database, you have to recreate it and assign the user to it again.

Found this useful? Share it with someone who runs a website.

Share this article