Your comprehensive guide for Twig front-end view templates.
CLI Equivalents for Common MAMP PRO and Sequel Pro Tasks
Last Updated
A version of this article appeared on viget.com
Working on website front ends I sometimes use MAMP PRO to manage local hosts and Sequel Pro to manage databases. Living primarily in my text editor, a terminal, and a browser window, moving to these click-heavy dedicated apps can feel clunky. Happily, the tasks I have most frequently turned to those apps for —starting and stopping servers, creating new hosts, and importing, exporting, deleting, and creating databases— can be done from the command line.
I still pull up MAMP PRO if I need to change a host’s PHP version or work with its other more specialized settings, or Sequel Pro to quickly inspect a database, but for the most part I can stay on the keyboard and in my terminal. Here’s how:
Command Line MAMP PRO
You can start and stop MAMP PRO’s servers from the command line. You can even do this when the MAMP PRO desktop app isn’t open.
Note: MAMP PRO’s menu icon will not change color to reflect the running/stopped status when the status is changed via the command line.
- Start the MAMP PRO servers:
- Stop the MAMP PRO servers:
- Create a host (replace host_name and root_path):
MAMP PRO-friendly Command Line Sequel Pro
Note: if you don’t use MAMP PRO, just replace the /Applications/MAMP/Library/bin/mysql
with mysql
.
In all of the following commands, replace username
with your user name (locally this is likely root
) and database_name
with your database name. The -p
(password) flag with no argument will trigger an interactive password prompt. This is more secure than including your password in the command itself (like -pYourPasswordHere
). Of course, if you’re using the default password root
is not particular secure to begin with so you might just do -pYourPasswordHere
.
Setting the -h
(host) flag to localhost
or 127.0.0.1
tells mysql to look at what’s on localhost. With the MAMP PRO servers running, that will be the MAMP PRO databases.
-
Create a local database: with the MAMP PRO servers running, run this (replace
username
with your username, which isroot
by default, anddatabase_name
with your database’s name)or
MAMP PRO’s databases are stored in /Library/Application Support/appsolute/MAMP PRO/db so to confirm that it worked you can run the following command to output the available MySQL versions
That will output something like
(Alternatively open the main MAMP PRO window and click on the MySQL “servers and services” item. In my case it shows “Version: 5.7.26”.)
Now look in the relevant MySQL directory
The newly created database should be in the list
-
Delete a local database: with the MAMP PRO servers running, run this (replace
username
with your username, which isroot
by default, anddatabase_name
with your database’s name) -
Export a dump of a local database. Note that these uses mysqldump not mysql (replace
username
with your username, which isroot
by default, anddatabase_name
with your database’s name)-
to export an uncompressed file
-
to export an uncompressed file
-
-
Export a local dump from an external database over SSH. Note that this uses mysqldump not mysql (replace
ssh-user
,ssh_host
,mysql_user
,database_name
, and the output path)-
to export an uncompressed file
-
to export an uncompressed file
-
-
Import a local database dump into a local database. With the MAMP PRO servers running, run this (replace
username
(root
by default) anddatabase_name
) -
Import a local database dump into a remote database over SSH. Use care with this one. But if you are doing it with Sequel Pro —maybe you are copying a Craft CMS site’s database from a production server to a QA server— you might as well be able to do it on the command line.
For me, using the command line instead of the MAMP PRO and Sequel Pro GUI means less switching between keyboard and mouse, less opening up GUI features that aren’t typically visible on my screen, and generally better DX. Give it a try! And while MAMP Pro’s CLI is limited to the essentials, command line mysql of course knows no limits. If there’s something else you use Sequel Pro for, you may be able to come up with a mysql CLI equivalent you like even better.
Articles You Might Enjoy
-
Fundamental Twig for Front-End Development
-
-
Git Prompt Kit: Configurable, Fast Git Status Components For Custom Zsh Themes
A collection of components for displaying Git information in your prompt