In this guide, you will learn how to migrate a WordPress site from one hosting to another hosting without using any plugin.
Migrating a WordPress site will require you to perform three tasks:
- Migrate WordPress files
- Migrate WordPress database
- Update database configuration and other configurations.
Backup WordPress Website Files
First of all, lets backup WordPress files. Then, we will need to restore these files to the new hosting.
You can find your WordPress website files and folders in a directory where your domain points to. Generally, it is a “public_html” directory. Or, it can also be inside of another sub-directory of “public_html”.
Here, we are taking the cPanel interface as an example of how these files will look like.
Next, compress the files and folders. Let’s call it “example.zip”. Later, we will upload and extract this compressed file in order to migrate them to the new hosting.
Export the WordPress Database
This comes in the second step where we need to export the WordPress database. In your cPanel, go to phpMyAdmin under the “Databases” section.
Here, you may see multiple databases. So, we need to find which database is being used by the WordPress site. You can find this by looking into the “wp-config.php” file.
When you open the “wp-config.php” file, you will see your database connection parameters like this:
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'example_wp101' ); /** MySQL database username */ define( 'DB_USER', 'example_wp101' ); /** MySQL database password */ define( 'DB_PASSWORD', 'Password@123' );
Here, the value corresponds to the “DB_NAME” is your database name. So, in this case, it is “example_wp101”.
In phpMyAdmin, find and click on this database. Then, navigate to the “Export” tab where you can export the database SQL file. Click on “Go” to export the SQL file.
Migrate WordPress Files to the New Hosting
Login to your new hosting where you are migrating the site to. Here, you may need to create a new sub-directory inside of “public_html” where your domain name points to.
Or, you can directly use the “public_html” directory if your domain points to the “public_html”.
Next, upload the “example.zip” which we have created earlier for the WordPress backup files. Then, extract this zip file inside of “public_html” of the new hosting where your domain points to.
After extracting the files, you can delete the zip file “example.zip”.
You may need to update the nameservers of your domain if you purchase this from a different hosting.
Create Database in the New Hosting
In this step, we will create a database in the new hosting. Later, we will import the SQL file which we exported earlier to this database.
To create a new database, go to “MySQL Databases” under the “Databases” section of your cPanel.
Here, enter the name of the database. Let’s call it “example_wp_201”.
Next, add a user to this database will all the permissions.
After adding the new user, you can assign this user to the database “example_wp_201”.
Migrate the Database to the New Hosting
Open phpMyAdmin in your new hosting. Now, we will import the SQL file.
First, select the newly created database “example_wp201”. Then, go to the “Import” tab and choose the SQL file “example_wp101.sql” which we exported earlier. Then, import the file.
Update wp-config.php for the New Database Connection
So, we have database imported and the WordPress files migrated. The last step is to update the database connection in the “wp-config.php” file.
In your new hosting, open the “wp-config.php” file and update the database credentials to reflect the new database.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'example_wp201' ); /** MySQL database username */ define( 'DB_USER', 'example_wp201' ); /** MySQL database password */ define( 'DB_PASSWORD', 'Password@321' );
Lastly, you may need to update the nameservers of the new hosting in your domain account where you purchase the domain.
If you face any issue when migrating your WordPress site, then you may want to contact us. We will get back to you as soon as possible.