This article covers the best way to move a WordPress site to a new host without any issues.
Steps to migrate a WordPress Blog to another host involves the below process:
- Sign up to a new host – Choose your new provider based on what's important to you.
- Back up your website's files – Use a plugin or an FTP protocol to save your files.
- Export your database from your existing host – Begin the transferring process from the control panel of your old host.
- Create a MySQL database on your new host – Create a new home for your old files.
- Edit the wp-config.php file on your website's files – Make sure the database information is up-to-date.
- Import your saved database into your new host – Upload your database.
- Upload your website's files to your new host – Upload your files from your local computer.
- Update your DNS settings – Make sure your domain's settings point to the new server IP address.
How to move WordPress website from localhost to a live server ?
Once you take a Backup of the local site, follow the steps given below:
1. Log in to your web server using your SFTP client of choice.
2. Navigate to your website files on your local computer. If you can see a wp-config.php file alongside directories like wp-content, then you’re in the right place.
3. Go to the public directory on your web server (right pane). This is typically a folder called 'public_html' or 'www'. This does vary from host to host, so check with them if you're unsure. If you’re hosting your site in a subfolder, you'll want to navigate to that subfolder.
4. Select all of the local files from the left pane and drag them to your web server in the right pane.
5. Import the data from your local database to your live database.
To do this, you first need to Export the database from localhost:
- Select your database.
- Click the 'Export' tab.
- Select 'Quick' as the export method, choose 'SQL' as the file type, and click 'Go'.
6. This will download a .sql file to your computer. Take a note of where this is saved, as you'll need to import this on your web server.
7. Create a database on your live server. To do this:
- In your hosting control panel, go to the 'Databases' section and click 'MySQL databases'.
- Create a new database.
- Create a database user. Scroll down to the 'MySQL Users' section and create a new user.
- Add the database to the user and assign permissions. To do this, scroll down to the 'Add user to database' section, select the user and database that you just created, and click 'Add'.
- Assign all privileges to the user account and click 'Make Changes'.
8. Edit your wp-config.php file and use the newly created database information.
9. Import the data that you exported earlier via phpMyAdmin.
10. Change the site URLs in your database. You'll need to ensure the database contains the new site URL, and not that of your localhost. Do the following:
- Open phpMyAdmin and select your database.
- Click on your WordPress options table. Tables usually appear on the left.
- Once opened, you should see the first two options. Under the 'option_name' column, you'll see 'siteurl' and 'home'.
- Double click on the option value under the 'option_values' column and change both of these to your new URL. Make sure you don't include a forward slash (/) at the end.
- Open your browser and type in your live site's url with /wp-admin/ at the end (e.g. https://yourwebsite.com/wp-admin/). From here, you should be able to login to your WordPress dashboard.
11. Flush your permalinks. To do this:
- Go to your WordPress dashboard and log in.
- Go to Settings → Permalinks.
- Click 'Save Changes'.
13. Search and replace localhost URLs in your database.
To do this:
- Log into phpMyAdmin on your web server, select your database, then click the 'SQL' tab.
- Copy and paste the following query parameters into the SQL query field:
UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost.test', 'https://newwebsite.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost.test','https://newwebsite.com');