Move WordPress from localhost to server without using plugins

If you develop your WordPress websites on a local machine you might be viewing at a URL like localhost:8888/yourdevsite/ which is fine until you get to the point you need to launch the website or move it online for a client to take a look. I’m going to show you how to move WordPress from localhost to server without using plugins.

The problem you’ll face if you copy the local database over to your server all of your internal links will be broken as they’ll all point to localhost. One solution is to create a completely fresh WordPress install on the new server and copy over just the theme and plugin files before re-inputting any content. This approach is OK for very small sites but is a huge pain if you’ve spent any time at all on this already. There’s also the chance that you’ll miss something. The other option is to update the URLs wherever they appear in your WordPress database.

There are a few different ways you can update the database. As with most WordPress tasks I prefer to do things without the use of a third-party plugin, especially if it something pretty easy like this. Ignoring the plugin route, you can either run an SQL command on your database or export and modify the database. I prefer the export option as it leaves the original database intact.

First, have you removed any insecure passwords?

Before we start, let’s take a moment to think about security. One mistake I’ve seen people make when moving a dev site to a live server is to leave a highly insecure admin account in place. I recommend using strong, hard-to-guess usernames and strong passwords even while in your local development environment. If you have an a user account called ‘admin’ with a password of ‘password’ then please make sure to change it while still in you local environment and before you begin this process.

Updating your database URLS in a text editor

Export your local database to a file

If you’re using PHPMyAdmin or MySQLWorkbench locally you can quickly export the contents of your database to a file which can be opened in a text editor like Sublime Text, BBEdit, TextWrangler or anything else.

In PHPMyAdmin just click the Export tab, choose the Quick option under Export Method, make sure the Format is set to SQL and then click Go. You’ll be asked to choose a location to save the file.

In MySQLWorkbench choose the Data Export option from the Server menu, and choose the database to export in the Tables to Export window. Lower down the screen you can choose al location to save the file where it says Export to Self-Contained File. Now just click Start Export and save the file.

Use a text editor to find and replace the URLs

Open your exported file in your text editor of choice. I use BBEdit for this. Now you can simply do a find and replace changing http://localhost:8888/yourdevsite/ to

Once that’s done save the file.

Import the updated file on your live server

Now move over to your live server and create the database through your hosting control panel, MySQLWorkbench or Terminal. Make a note of the database name and password for later.

Now you need to import the database file you modified and saved in the previous step. In PHPMyAdmin you do this from the Import tab. In MySQLWorkbench it’s the Data Import option, which you’ll find in the Server menu again.

Upload your WordPress files

You will also need to move your site files of course as we’ve only ported across the database so far. I like to do this with SSH but if you need to use FTP that’ll work too. Just copy your complete local site including all WordPress files, plugins, theme files and uploads to wherever they’re going to live on the live server.

Update your WordPress configuration file

The last part of the puzzle is allowing WordPress to connect to the database. To do this edit your wp-config.php file to point to the new database name and password. After you’ve done that you should be able to view the site in its new home including all your previously entered content.