How to move WordPress website from localhost to live server, Localhost is a test environment where every user can build a website and start a site with all the features needed on it, but most likely you want to get this site to the live server and show on the world wide Internet,
A question will be created for you that should you skip the website you have created in the localhost server and start building that website again?
In this tutorial, we’ll Show you how to transfer the site that you created in the localhost server to the live server environment.
Step 1 – Export the database
Content and text in WordPress are not stored in HTML or Text files, but stored in the WordPress database, MySql, and retrieved from the database when the site is displayed.
To transfer from the localhost server to the live server, you must first take copy a database, or take the export process of Database.
To do this; if phpMyAdmin is installed (in the program like Xampp by default) go to the database that you have dedicated to WordPress (that is, the database you created when installing WordPress).
Select the “Export” option from the toolbar (as in the image below)
Click the Go button at the bottom of the page to give you an export file of SQL.
Step 2- Upload file to live Server with FTP
In the next step, the files that are available on the local hosts WordPress must be uploaded to the new live server, At this point, you will need an FTP or data transfer software to upload files to live server, with help of your favorite FTP software, upload all the WordPress files you use locally on the server.
We do this in the following way. Just need to have all the information to connect with FTP account to live server
Usually hosting companies provide this information, but if not, in the environment itself there is a part to build FTP that you can build.
Step 3- Build a New MySQL database
At this point, you need to create a new database on a live server to import the previous database that you used on localhost server for your WordPress website.
To create a database on the server, depending on which panels you use, the way to create the database is different.
In the following, we’ll explain how to create a database in the DirectAdmin Panel as well as the Cpanel. The two are almost identical, but we explain for both of them if both users are having trouble it can solve their problem.
Create Database with DirectAdmin Panel
In the DirectAdmin, click on the “MySQL Management” option after logging in to the admin panel. And then on the Database Management page, click the “Create New Database” button to open the database profile window.
After entering the information, click the “create” button to create the database. The database profile is created after you create it. Keep it or note it as you will need it in the next steps.
Create Database with cPanel
in the cPanel you will see several windows after you login to your cPanel, in the Database Section Click on the MySQL database, to create a new database.
Now you are entering a window that asks you to create a database name.
After entering the name and title for the database, next, you will enter a step to write the username and password of the database, which you must also enter the information correctly.
In the lower part called Add user to Database, click on the Add option and check all the items in the window that opens to you.
Now are done with all the Primary Process.
Step 4- Import the old database
Now that a new database has been created, you need to import the database that you have from your Localhost Server.
You can do this process with help of phpMyAdmin, PhpMyAdmin is commonly found on hosts. You can find it in thirteen panels on the same page, and in the admin directory on the MySQL Management page, under the “Create New Database” option, there is the option phpMyAdamin, through which you can access the program.
After running click on the name of the database you previously created, select import button in the toolbar above.
And then, as shown in the image, click on the “Choose File” button to select the file that you have exported from the local, and then click the Go button at the bottom of the page to import the database.
Step 5 – Correct WordPress URLs
Now we have to tell to WordPress that I found a new home and no longer in the local area. To do this, we need to correct the site’s address. That’s simple.
In phpmyadmin, click on your database (the database you created), then select the “options” table from the database in phpMyAdmin, and in the pop-up window, follow the “siteurl” field and click on the pencil button (edit) Edit the field where the local address is located and enter the address of the new site that is on the live server.
The following three illustrations show these steps:
Step 6- Start the site
After completing all the steps mentioned above, you are likely to encounter a database connection error! We’ll fix this together.
To do this, connect to your FTP server and go to the wp-config.php file. We want to edit this file. Enter all the name of the database name, username, password we created in our database, and save our changes. Currently, our site is visible.
log into your WordPress panel and then go to Settings >> General and click on the Save option. This will cause your site to be properly registered everywhere.
Then go to Settings >> Unique Links and click on the Save Settings button to fix all the unique links.
Step 7 – Update broken links and images
Usually, when you transfer your WordPress site from local to host or from domain to domain, your links or images are broken up and are called broken links.
This problem can be solved by the plugin, but if you do not want to use the plugin you can solve this problem through your database. Just go to phpmyadmin and click on the SQL tab from the top menu and then the sample code below for I put you in there. Just remember to enter it according to your profile.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');