In the last two chapters, I talked about Installing WordPress Locally and Building Custom WordPress Theme. This chapter will cover exporting your local WordPress to a web host. Assume you are done with the local WordPress development, it is time to learn how to export and import WordPress. Then you can keep the local version for backup purpose and future development (ie. testing new themes, plugins, and upgrades).
1. Export Local Database
Login to your local phpMyAdmin, select the database from the dropdown. Click on the Export tab:
- Under the Export field, make sure all tables are selected
- Under the Structure field, tick "Add DROP TABLE / DROP VIEW"
- Tick "Save as File"
- Then click Go and it will prompt you to download a SQL file

2. Find & Replace All Local URLs
Open the database SQL file with a text editor. Find and replace all local URLs with your domain URL (eg. replace all "http://localhost:8888/mysite" with "http://www.yourdomain.com").

3. Import The Database
Login to your server cPanel, go to MySQL Databases, create a new database and assign a user. Now go to phpMyAdmin, select the database (the one that was just created) from the dropdown, click on the Import tab, browse the SQL file and click Go.

4. Upload WordPress
Upload the entire WordPress folder to your server.
5. Change The wp-config.php Setting
On your server, open the wp-config.php file. Change the database details to reflect your server settings.

6. Done
Go to your website and everything should work perfect.
I have followed the tutorial so many times, but its not working for me I am afraid. it apprears that only the home page is working and nothing else, the links for pages, images are not working WHATSOEVER
I have been on this code for about a week now and I can’t find a solution, I even replaced all the links in all localhost/mysite files with my website domain (because you see I want to see my site under the domain, not domain/wordpress folder); but alas I am bereft of Ideas
please any suggestions are more than welcome here!!!
I’m having the same problem as calliope, everything works perfectly locally but once I moved the site to the server none of my links work.
I was having trouble with importing the database to the server, so I did a fresh install and imported all my posts and pages, they are all showing fine in admin but any links to pages or posts return a 404 page not found error and even previewing posts or pages from the admin does the same thing.
I’m pulling my hair out, any ideas?
Hi, what´s is wrong when the css not seams to be active and when a click on a link it point me to my http://www.xx.com and not to my subfolder. where everything is placed.
Thanks—you just helped me loads!
Thanks a million, it on the worked second time. That’s excellent for me.
I had to make sure step 2. (Find & Replace All Local URLs) was entered correctly.
From the bottom of my heart thank you. Muzza!
Comment Guidelines
If you have uploaded any attachments you will want to change the path(s) to the file(s) as well (/path/to/local/site/test.jpg -> /path/on/host/server/test.jpg).
When make any replacements you need to use caution and watch for changes made in a serialized value. It is likely you will be changing the length of the string and this may cause the serialized value to break.
If you do make a change to a serialized value you simply need to update the string count (s:5:”tests”; 5 in this case) with the correct count.
yes man,
thanks a lot
me too i can work offline
my best regards
Thanks .. your guidance is very helpful for a newbie like me.
well if you have a BIG database, it will be a little annoy to open de .sql and chage and replace..
I think is better doing this .
After you import your DB to the new location…
then you should make a quary.:
To update WordPress options with the new blog location, use the following SQL command:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as absolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');Browse through WordPress blog to check if everything is okay. You also need to re-login to WP Administration as authentication cookie has now became invalid due to different domain.
Remeber always to have a backup
see’a
Great Tut.
THANK YOU FOR ALL YOUR TIME DOING THESE FOR ALLLLL OF US! Unfortunately, I am having an error though when I try and import the db ‘localhost.sql… I have tried a few times now – It says:
Error
SQL query:
–
– Database: `information_schema`
–
CREATE DATABASE `information_schema` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
MySQL said: Documentation
#1044 – Access denied for user ‘root’@'localhost’ to database ‘information_schema’
Any help would be so appreciated.
Thanks!
what about if i want to set one up in another folder say .www.example.com/themes
the themes folder being the folder where i would want to put wordpress in, anything to watch out for?
thank you
it worked with me very well
WordPress 2.7+ finally has an import/export wordpress option. First step is to upload your theme to the themes folder on your server, then on your local host, export the wordpress file (it’s an xml file), and on your live site, upload it. Voila, done.
Hi! I’m planning to move from one server to another and I’m using drupal. Do i follow the same process for drupal as well?
Hi, you said this is for backup purposes. So, if someone creates a new post in WordPress, will it automatically show up in the website or does it need to be imported each time? I am new at using blogs and trying to find better ways to incorporate them into a site.
Thank you!
Thanks for the post. You made it so easy! But I read it somewhere. It is best that you uninstall the theme first.
You rock! Thanks for the step-by-step. It was very easy with your help. So many other tuts are way too technical for designers. I created my first theme locally and put it up live today!
Thanks again! Calvin
Thanks man, this is great. I learn a lot from your tutorial, in fact, I created my web following your guide here starting from install WordPress Locally, Useful WordPress Plugins, and finally this one… Export my web.
You Rock!
Hi,
Thanks a lot for this – I was able to export/import my WordPress but at first my images weren’t being uploaded to the right place (I use Windows Live Writer)
The problem was that in my .sql file, the ‘upload_path’ was hardcoded to ‘xampp/htdocs/wp-content/uploads’, which lead to my images being uploaded to the wrong place. I had to replace this with my siteurl (which was not detected when I did a localhost find and replace) to get it working.
It cost me a day in coding so I’m hoping that I can help shed some light on those who come across the same problem.
Excellent tutorial though! :)
Cheers,
Adam