I’m going to show you how to use phpMyAdmin to back up and restore MySQL databases. In my next post, I’ll show you how to graduate to doing the same thing using the command line.
phpMyAdmin without the MAMP frame
First things first. Let’s work so we can see what we’re doing.I’m going to assume that you’re able to download and install MAMP or MAMP Pro on your own. The phpMyAdmin URL that you from the MAMP default webstart page gets you to the URL:
which looks gives you a framed version of the phpMyAdmin. The framing takes up a lot of screen real estate.
Instead, use http://localhost/phpMyAdmin and you’ll get something that looks much more pleasing:
dumping a database with phpMyAdmin
Select a database from the drop-down menu on the left hand side of phpMyAdmin. Or, Navigate to “home” by clicking the little house under the phpMyAdmin logo in the top left and hit the blue Databases link in the longish list there.
Ok, so now we see the tables in our database. Press the Export tab at the top. We’re going to export this database.
Let’s review the options you should select to get nice, compact, and legible SQL.
The first column, in the Export fieldset, is pretty straight forward. By default all the tables in your database will be selected. SQL is the format you want too.
“Disable foreign key checks” isn’t always necessary. I do a lot of CiviCRM work. Restoring a CiviCRM database will fail unless this option is enabled in your export.
“Add DROP TABLE / DROP VIEW” will delete your table on import before recreating it.
Extended inserts and Complete insterts gives you a smaller file and more compacted, easy to read view.
Click “Save as file” and use “gzipped” compression for the smallest files.
In the File name template, I add %D, which spits out today’s date. I add a little hypen before to seperate it from the database name and MAMP after, so I know it was a local dump and not from my live server. This format would give me a file like: mysql-06_02_09_MAMP.sql.gz
To restore your databse, click on the import tab, click the browse button, select your file, press go. I’ll spare you the screenshot.