Having depended on MAMP and PHPmyadmin for as long as I’ve been doing this stuff, moving to Vagrant presented me with a very real fear that I wouldn’t be able to easily setup local installs of live sites. With MAMP I had always done a find and replace through the old Replacr app and then uploaded the DB through PHPmyadmin.
It wasn’t perfect but served my needs for any db under 50MB. Sadly as I have been tasked with older installs and larger DBs that restriction has become problematic. Fortunately Vagrant once again steps in to save my butt.
This is mostly a command line process but I promise it’s pretty basic, much faster than my previous mostly manual solution, and isn’t restricted to the PHPmyadmin file size limits. These steps while specific to Vagrant make use of the WP-CLI which is not specific to Vagrant. You could probably do this with MAMP and can definietly do this on your server if you set it up proper.
db import in vagrant
This assumes you installed vagrant at the default location of vagrant-local
Make sure that the db you will be importing is the same name as the db you will be importing into. So if your local site has a database name of
EXAMPLE.sqlyou need to make sure that the db you will be import also has a name of
Make a copy of the db you will be importing and move it to the root directory of the site you will be importing into.
ssh into vagrant
cd to site
wp db import DATABASE.sql
Search and Replace (optional)
If you need to do a search and replace run the following command. It handles serialized data appropriately so you don’t bugger up your site.
wp search-replace 'http://example.com' 'http://example.dev'