Chris Walton

Working with MAMP and Terminal, import and delete a local database

Command line, its a scary prospect and not something many of us have gone near since our University days, but its a good knowledge set to learn or refresh on when spending time building and maintaining websites.

Import a database

Importing Databases to your local server is a common activity which is easiest to perform through command line, especially when dealing with larger databases common with platforms like Magento.

So the first thing to do is to pop open a terminal window
/Applications/MAMP/library/bin/mysql -u user_name -p database_name < /Users/user/Documents/database_import.sql
You will then be prompted for your mysql server password and after a short (to lengthy) delay your database will have been imported.

Delete Databases

In the instance you need to delete a database for whatever reason open up your preferred method of editing your database (PHP MyAdmin, Sequel Pro or Terminal being 3 options) and perform the following

DROP DATABASE database_name;