Dive into the intricate steps of uploading a WordPress site with this comprehensive tutorial, discussing topics such as exporting a database, modifying SQL for appropriate absolute URLs, and the process of uploading WordPress and importing a database.
This exercise is excerpted from Noble Desktop’s past WordPress training materials and is compatible with WordPress updates through 2020. To learn current skills in WordPress, check out our WordPress Bootcamp and coding bootcamps in NYC and live online.
Topics covered in this WordPress tutorial:
Exporting a database, Modifying the SQL to use appropriate absolute URLs, Uploading WordPress, Importing a database
Exercise Preview
Exercise Overview
Once you are satisfied with the way the site looks and functions, it’s time to upload it to the remote web server. This exercise was written for use at your home or office, and is similar to Exercise 4D. In this exercise, you will sign up for a free test hosting account with 000webhost.com and upload the WordPress site to their server.
Signing Up for a Free Hosting Account
Open a web browser and go to 000webhost.com (those are zeros at the beginning of the URL).
Click the Free Sign Up button on the right.
Under Start Free Sign Up, enter your Email, Password, and Website Name (subdomain). So you don’t forget them, write them down (you’ll need them later).
Click Get Free Hosting.
If you see it, fill out the CAPTCHA.
Once your site is finished being created, you’ll receive an email (it may be in your Junk folder). Click the link in the email to confirm your registration and return to the 000webhost site.
In the dialog that appears, click It’s ok, I want to learn.
Click the Manage website “Website Name” button.
Under Build website take note of your full domain (you’ll need this later).
In the top-right corner, go into the Settings menu and choose General.
-
You will need the FTP details to upload your site. So you don’t forget them, take note of the following (you’ll need them later):
- Host Name (should be files.000webhost.com)
- Username
- Password (same as website login password)
Let’s see how the website looks. Under Website Settings, click the link to your website, This is just a default page—you will be replacing it shortly.
Exporting the Database
WordPress stores all the posts, page content, and comments in a MySQL database. We can easily transfer all our site content from the local version to the remote server by transferring the database.
-
Start your server and open phpMyAdmin, as shown below:
Mac
- Open the MAMP application.
- Servers should start automatically; if not, click Start Servers.
- Click Open WebStart page if the MAMP start page doesn’t automatically open in your default browser.
- On the start page, in the nav menu, go to Tools > phpMyAdmin.
Windows
- Open XAMPP.
- In the control panel, ensure the Apache and MySQL services are running.
- Open your browser and go to localhost
- On the start page, on the left sidebar, under Tools, click phpMyAdmin.
-
Click the mrp database from the list of databases on the left. This is the WordPress database that stores everything.
-
On the following page, click the Export tab:
-
To finish exporting your WordPress database, follow the appropriate directions for your operating system:
Mac
- Under Export Method, choose Custom.
- Under Table(s), click Select All to make sure all the tables are selected.
- Under Output, choose Save output to a file.
- Under Object creation options, check on Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement.
- At the bottom of the page, click Go.
Windows
- Under Export Method, choose Custom.
- Under Object creation options, check on Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement.
- At the bottom of the page, click Go.
-
If a pop-up window appears, Save the file into your Downloads folder. (If you are using Chrome on any platform or Safari on a Mac, it won’t open a pop-up window; it will just download the file.)
NOTE: By default, most web browsers will download files into the Downloads folder on your machine. Depending on whether you have changed your preferences, the file may download into another location other than the Downloads folder.
The mrp.sql file will now be downloaded and placed in your Downloads folder.
Replacing the Local URLs
WordPress uses absolute links for almost everything in the database, so we need to change all the local paths to the new remote path. Currently all the links stored in the database are linking to localhost:8888/mrp (Mac) or localhost/mrp (Windows). This would cause linking issues if you were to import the database directly to your remote server now. The easiest way to fix this is to do a Find and Replace in your code editor.
Open your code editor.
Choose File > Open.
- Navigate to your Downloads folder (or the folder that mrp.sql was downloaded to):
- Mac: [username] > Downloads
- Windows: C: > Users > [username] > Downloads
Open mrp.sql.
-
Go to the following to do a Find and Replace:
- If you are using Sublime Text, go to Find > Replace.
- If you are using Dreamweaver, go to Edit > Find and Replace.
-
Enter the following (the Find and Replace labels may be named differently in your code editor):
Find: http://localhost:8888/mrp (Mac) or http://localhost/mrp (Windows) Replace: Enter the full URL of the site you wrote down earlier in this exercise (including http://). Click the Replace All button.
Save the file.
Importing the Database
Go to 000webhost.com/members
Enter your email and password and click Log In (if you’re not logged in already).
Along the top menu, click Manage database.
Near the bottom right, click New Database.
-
Create a new database, user, and password:
Database name: mrp Database username: user Password: passw0rd (the letter o is a zero) When complete, click Create.
- On the following page, it will display important information regarding the database. Write it down because you’ll need it later.
- DB Name
- DB User
- DB Host
NOTE: Your database username (DB User) and database name (DB Name) have been prefixed with a series of numbers. Your password has not been changed.
On the right of the database table, click Manage > PhpMyAdmin.
This should take you to the phpMyAdmin page. Enter your new database Username and Password.
Click on your database name from the list of databases on the left.
-
Click on the Import tab.
Click the Choose File button (in some browsers it is Browse).
Go to the Downloads folder where the mrp.sql file was saved.
Double–click mrp.sql
At the bottom of the page, click the Go button. It should import your database. You’ll know it worked if you see a message at the top that says something like: Import has been successfully finished, 69 queries executed.
FTP Clients
While there are many great FTP Clients you can use for uploading your website to a remote server, we choose to use Cyberduck in this workbook because it is free and cross-platform. Rest assured: if you choose to use a different FTP client, it will involve the same simple steps we outline in the exercise.
Uploading Your WordPress Site
Launch Cyberduck.
Click the Open Connection button at the top left of the main window.
-
Next to the following fields, enter the information about your website (NOT the database you just created) you wrote down earlier in the exercise. If you forgot, this info is accessible by going to 000webhost.com/members and going into the Settings > General.
Server: Enter the FTP host name (should be files.000webhost.com) Username: Enter your FTP user name Password: Enter your FTP password (same as website login password) -
To connect to the server, click Connect. If you get a warning that you have an Unsecured FTP connection, just hit Continue.
NOTE: If Cyberduck cannot make a connection, double-check your username and password as well as making sure there are no extra spaces.
Double–click on the public_html folder.
-
Once connected, you will see the window that lists the files for your site.
TIP: Once connected, you can choose Bookmark > New Bookmark to save all this information for future use.
You are now ready to upload your files. In order to do this, move the Cyberduck window to one side so you’ll be able to see your local file folder next to it.
- Open a Finder (Mac) or Explorer (Windows) window and navigate to:
- Mac: Hard Drive > Applications > MAMP > htdocs > mrp
- Windows: C: > xampp > htdocs > mrp
Arrange this window and the Cyberduck window so they are side-by-side.
In the mrp window, select all of your local files by clicking on any file and pressing Cmd–A (Mac) or Ctrl–A (Windows).
-
To put your files on the live site, simply drag the selected files and folders from your computer’s window onto the Cyberduck window. TIP: Be careful not to drop the files into any existing folders.
If you get another warning that you have an Unsecured FTP connection, just hit Continue once more.
-
A Transfers window will appear, showing the progress of the upload (it will take a while).
If you get an Overwrite window or a warning about overwriting the pre-existing files and folders, just hit Continue to overwrite those files with your own.
Once it has finished uploading, you can go ahead and close the Transfers window.
Editing the wp-config.php File
When the site is finished uploading, you need to connect it to the database you uploaded to the remote server.
Switch to your code editor.
- Open wp-config.php from the mrp folder located at:
- Mac: Hard Drive > Applications > MAMP > htdocs > mrp
- Windows: C: > xampp > htdocs > mrp
-
Save the file as wp-config-remote.php into the mrp folder. This will be the config file that we upload to the live server.
NOTE: You may be wondering why we don’t just edit the wp-config file instead of making a copy. By making a copy of the file, we will still be able to work on the site locally if we wanted to.
-
Update your MySQL settings around line 18 with the information you wrote down earlier in the exercise:
/
**The name of the database for WordPress
*/
define('DB_NAME', 'XXXXXXXX_mrp');
/
**MySQL database username
*/
define('DB_USER', 'XXXXXXXX_user');
/
**MySQL database password
*/
define('DB_PASSWORD', 'passw0rd');
/
**MySQL hostname
*/
define('DB_HOST', 'mysqlXXX.000webhost.com');
Save the file.
Switch back to Cyberduck and the Finder (Mac) or Explorer (Windows) window.
Drag the wp-config-remote.php from your computer’s window onto the Cyberduck window. If you get another warning that you have an Unsecured FTP connection, just hit Continue once more.
-
A Transfers window will appear, showing the progress of the upload.
If you get an Overwrite window or a warning about overwriting the pre-existing files and folders, just hit Continue to overwrite those files with your own.
When the file has finished uploading, you can go ahead and close the Transfers window.
In the Cyberduck window, Ctrl–click (Mac) or Right–click (Windows) the wp-config.php file and choose Delete. (If a dialog appears, click Delete.)
Still in the Cyberduck window, Ctrl–click (Mac) or Right–click (Windows) wp-config-remote.php and choose Rename.
Rename the file wp-config.php
Go to the domain you were assigned to check out your live site! The MRP website should load. Awesome!
If you get a database connection error, double-check that you entered the correct information in the wp-config-remote.php file. Correct any mistakes you may have made, then repeat the previous steps to upload the file again.