Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Importing/copying a buddypress mirror locally using MAMP

@victor_moura – glad to help.

define(‘DB_NAME’, ‘whatevernameigivethedatabase’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘root’);
define(‘DB_HOST’, ‘localhost’);

root/root is the default username / password combo for MAMP. Obviously you should never have it set like this on a live public server because it’s instantly hackable, but on your local MAMP (assuming you haven’t got it set up to actually serve a Live site for a client to see online) it’s fine.

(When setting up a brand new site from scratch, you can also change your database table prefix (the setting is found in wp-config.php) for extra security. Google this to learn why it’s a good idea.)

b) I use MAMP Pro which comes with phpMyAdmin built in. phpMyAdmin can be launched from MAMP Pro’s interface. When I’m setting up a site I create a folder in my browser bookmarks for local, and one for remote. Aside from the site URLs, I bookmark the phpMyAdmin interface for both local and remote, so I can get to either database in a single click. Obviously, with the remote database it will ask you to log in during the loading, since to bookmark it initially, you’ll need to access it from your website’s cpanel (or wherever you launch phpMyAdmin from at your web host) and to do that you’ll need to be logged in to your host.

So, go into phpMyAdmin, click “localhost” (top left of main content area) to check you’re on the “home” page, and you’ll see an input field (“Create new database”). Name your db, and click Create (that’s all, no need to touch anything). This will create an empty database (a “shell” if you like) ready to be filled. I find it helpful to name the remote and local dbs differently (otherwise it’s too easy to get confused / messed up) .

3. Then click “Import”, find your backup and load it. At this stage, absolute URLs in your site will be wrong (they’re pointing to the address of your remote web server, not at your local MAMP server). To correct this in one easy find and replace (whilst protecting the structural integrity of your database tables – very important!) use http://spectacu.la/search-and-replace-for-wordpress-databases/ (it’s a very powerful tool, treat with caution).

Once you’ve got the hang of it, it’s quick. From starting a remote backup to running that db as a local mirror takes me about 30 seconds.

i. when I’m loading in a remote db, I always delete the local one (to do this go to “localhost” in phpMyAdmin, click the name of your db in the left hand column and when it’s loaded click “Drop” – it means “Delete” – it’s top right, in red), make a new local one, and load the remote db into this fresh “shell” – just to make sure everything is exact. You can delete the local db from within phpMyAdmin. Incidentally, this usually isn’t the case on a remote database (usually, to delete the remote db if you need to, you have to go into cpanel and select “Database Tool” or something similar).

ii. When saving the remote db, I select these options (you should Google this stuff) :

Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT
Add IF NOT EXISTS
Complete inserts
Extended inserts

Select “save as file” and “gzipped”. Don’t mess around with the dump, or unzip it.

All of this works for me, with my particular setup. I can’t stress enough how important it is to do thorough testing, to be certain that the backups you make actually work.

There are several standalone tools out there for more comprehensive db management, but phpMyAdmin works great for me at this point, and it’s so convenient having it all in the browser. What makes MAMP Pro so good is being able to set up multiple virtual servers – sometimes I’ll run several local mirrors of the same site so that I can try out different things and easily compare the results.

Skip to toolbar