Creating a Local Copy of Your WordPress Site Using MAMP
20th of May, 2009 in the year of our Lord
I presented my portfolio on May 11th using a local copy in case there were any problems connecting to the internet and because our campus network is slooooooooow.
I found a few tutorials on how to create a local copy of an existing WordPress installation, but they were all very slightly off for someone using MAMP. I first got MAMP when I was learning how to install WordPress locally and since it works great, I didn’t want to install another local server environment.
Anyway, on to the instructions:
Exporting Your WordPress Database
- Log in to phpMyAdmin through your host (usually in the cPanel). I use lunarpages so I’ll tell you how to get there on their site:
<!–– Dave Hubler kindly left a comment on a slight difference for those using limedomains as their host. Thanks, broseph. ––>- Log in by clicking the link in the header.
- Make sure you have the right hosting account selected in the drop-down menu and click Control Panel. If you have more than one hosting account, you’ll have to click the “Go to cPanel” button.
- Click on MySQL Databases among all the icons and scroll all the way to the bottom and click on the “phpMyAdmin” link.
- Select the WordPress database from the sidebar on the left. Remember this database name for a future step.
- Click the Export tab at the top, make sure everything is selected in the box on the left, the SQL radio button is selected, and the Data checkbox to the right is checked. Select the Save as file checkbox and click Go.

Importing Your WP Database into Your Local Copy
- Download, install, and open MAMP if you haven’t already.
- Using your FTP client, copy your site’s root folder to /Applications/MAMP/htdocs/
- Go to the MAMP Start Page and click on phpMyAdmin.
<!-- NOTE -->
If for some reason MAMP didn’t start the servers and open the start page upon launch, do so now by clicking the buttons in the UI. - On the phpMyAdmin homepage there is an option to create a new database. Enter the database name from step 2 in Exporting Your WordPress Database and click Create.
- Click on the new database in the sidebar on the left then choose the Import tab at the top.
- Click Browse and select the database file you downloaded earlier. Click Go in the bottom left.
![]()
Setting Up Your Username and Password for Your Local Database
- Go to the homepage of your local phpMyAdmin and choose Privileges from the MySQL column on the left.
- Click Add a new User under the list of existing users.
- Enter your username and password from the remote database.
<!-- NOTE -->
If you don’t remember your username and password, open your wp-config file and get the info there. - For Host, choose Local if the host in your wp-config file is localhost. Otherwise, choose Any.
- Click Check All under Global privileges and click Go.
Setting the Proper URL
- Go to the homepage of your local phpMyAdmin and choose your database from the column on the left.
- Select Browse next to the table wp_options.
- Find the option_name siteurl and click the corresponding edit link. Change the option_value to http://localhost:8888/root_folder_name and click Go.
<!-- NOTE -->
If using something other than MAMP, you’ll probably have to type http://localhost/root_folder_name - Find the option_name home and set the option_value to the same as you did for siteurl.
![]()
![]()
That should be it!
Make sure MAMP is running and check http://localhost:8888/root_folder_name (or http://localhost/root_folder_name) to see your local site.



12th of December, 2009
OMG enjoyed reading your article. I added your feed to my google reader.
17th of December, 2009
Thanks a bunch for this! The tutorial was super useful and easy to follow.
12th of January, 2010
wow Curtis I really like the design of your site. Thanks so much for this helpful tip. I had ‘localhost’ instead of ‘localhost:8888′ in my site_id and it kept showing up wrong. Thanks to your site I fixed it easily. Great job!
13th of January, 2010
Thanks for the tutorial… in my case, when following the steps below, MySQL returned error #1007 – Can’t create database, database exists.
Instead of creating a database and THEN importing I just imported the .sql file I downloaded from my host. phpMyAdmin automatically created the database for me and it worked like a charm.
“On the phpMyAdmin homepage there is an option to create a new database. Enter the database name from step 2 in Exporting Your WordPress Database and click Create.
Click on the new database in the sidebar on the left then choose the Import tab at the top”
Just as a note my hosting provider is limedomains.
4th of June, 2010
how do I do the reverse with a wp site on wamp to shared hosting? It seems like all the links are pointing to localhost/wordpress_2.9.2/wordpress/ instead of my domain… I went in and replaced all references to localhost with mysite.com(example) in the database but it still screws up… is there an easy way to migrate from localhost to shared hosting? thanks
4th of June, 2010
yessireebob. check this out.
15th of June, 2010
:O ZZOMG!!1
It wanted me to search and replace the url’s in my database tables! That ‘might’ work, but you don’t want to edit the content of the tables directly… I actually humored the tutorial and tried that and didn’t have as much success. Maybe I missed something… anyhow…
A safer way to do the same thing is to:
—> on my localhost
-Make a backup of the DB. Use phpmyadmin (call it ‘local.sql’ maybe) as well as the WP directory tree.
-Go to admin and simply change the URL that wordpress points to as the desired webroot
-Export the DB again with those changes. (call it ‘migrated.sql’ or something) make sure to select ‘CREATE DATABASE’ option in phpmyadmin.
[This effectively points your local WP there as well, so go back to your local DB and recover the original backup (local.sql) made in step one.] – recover local DB, then it should point back at localhost.
—> on my server
-Install WP directory tree to server’s web root (/var/www/ on apache2)
-Install ‘migrated.sql’ DB on server’s mysql. Use phpmyadmin or
http://www.devshed.com/c/a/MySQL/Backing-up-and-restoring-your-MySQL-Database/
Tweek where needed.
15th of June, 2010
that’s actually what i normally do… i thought i got that from the link i sent you… maybe it was from the wordpress site…
18th of June, 2010
Searching and replacing instances of a url in a sql file is potentially dangerous (technique might break on newer versions…). After looking it seems like changing the url wp points to is pretty much the safest and most universal technique.
PS
Don’t forget to back stuff up.