Skip to content

Instantly share code, notes, and snippets.

Last active March 1, 2023 14:40
  • Star 21 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
MAMP to Valet

MAMP to Valet

One-time Dependency Setup/Configuration

Install Composer

wget && chmod +x composer.phar && sudo mv /usr/local/bin/composer && composer self-update

Install Homebrew

/usr/bin/ruby -e "$(curl -fsSL"

Run brew update just to be sure everything is up to date.

Install WP-CLI

wget && chmod +x wp-cli.phar && sudo mv /usr/local/bin/wp

Install Laravel Valet globally

composer global require laravel/valet

Ensure Composer global bin is in your $PATH

which valet >/dev/null 2>&1 || echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> "$HOME/.bash_profile"

Restart your terminal or source "$HOME/.bash_profile"

This also assumes you are using Terminal/iTerm. If you are using a different shell, eg: zsh, you should know how to update your $PATH accordingly


Settings > General Tab:

  • UNCHECK: Start Apache and MySQL on system startup
  • UNCHECK: Start Apache and MySQL when opening MAMP PRO
  • CLICK: Set default MAMP ports
  • Save

MAMP is now running on the default non-standard ports so it won't be conflicting with our new local services. You can continue to use it to host your databases if you want (instead of Homebrew installed MariaDB or MySQL), but it would require more effort than to switch over.

Export all the things!

Export All Databases from MAMP (optional)

mysqldump -u root -p --all-databases > ~/mysql-all-databases.sql

where -p is -pyourRootPasswordYesThereIsNoSpaceThere (leave as-is for blank password) This will export all databases to a file named mysql-all-databases.sql in your user's home directory.

Run this to ensure its available brew services

Start up MariaDB

brew services mariadb start

All mysql commands should now be targeting mariadb instead of MAMP's mysql. New credentials are: username root, password `` (empty). To check this, run which mysql It should now be `/usr/local/bin/mysql`

Import all databases

mysql -u root -p < ~/mysql-all-databases.sql

Run Valet setup

valet install

Congratulations, Valet is ready to go!

Let's try it out...

From the terminal, navigate to the directory which holds your projects/websites. (Easy way - drag the folder from Finder onto the Terminal icon - a new terminal window will open for that directory)

Run valet park It should say "The ____ directory has been added to your paths"

Now, if your project directory has a folder in called "example", you can now open your browser and go to and it should magically work!

Until now, the instructions have been totally framework agnostic, as Valet supports many.

Using Valet with WordPress

Note: the previous DB_* credentials in wp-config.php will likely need to be updated for the new database. Make sure you update these to reflect the proper DB_USER -> root and DB_PASSWORD -> `` (empty string).

Creating New Sites in a Single Command

One last thing to install...

wp package install aaemnnosttv/wp-cli-valet-command

Meet your new single command workflow

From that same directory, or any other directory you have "parked", run:

wp valet new my-project

Congratulations, you now have a fresh new install of WordPress in the my-project directory, available RIGHT NOW in your browser at


Copy link

kossa commented Feb 11, 2020


When I run mysql -u root -p < backup.sql I got this error

Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

Copy link

kossa commented Feb 11, 2020

Seems like "mysql" command linked to mamp pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment