How to install Homebrew, PHP, WP-CLI, MySQL on Mac and export database MySQL from Mamp

Posted on: August 4th, 2022
By: Tadeo Martinez

How to export database from Mamp

Be sure to be in the right directory, read Export / Import Large Database from MAMP using Terminal to see the right directory you need to be in. Which I’ll just add below:

cd /applications/MAMP/library/bin

Here’s the command to run to export the database:

./mysqldump -u dbusername -p dbname > filename.txt

It will prompt for the database password, it’s usually “root

To move the file to another direcotry:

mv filename destinationfolder

In my case, I usually move the file to my desktop (/Users/efrainlemus-martinez/Desktop) so it’s easier to drag in FTP.

To copy the file over to another folder:

cp -rf filename destinationfolder

To do a search-replace to update the home and site URL you can use the following command

wp search-replace '' '' --precise --recurse-objects --all-tables

Here’s the WordPress documentation on the wp search-replace command.

You can also check the site/home URL

wp option get siteurl

To set the site URL, run the following command

wp option set siteurl "new-url"

To set the home URL, run the following command

wp option set home "new-url"

Don’t forget to flush the cache

wp cache flush

The site and home URLs usually go hand-in-hand when you run them together.

Install PHP, WP-CLI, and MySQL

I was trying to export the database from MAMP with:

wp db export

But it kept saying command not found: wp. Long story short, that opened a can of worms that lasted about a day until I re-installed homebrew and then I was able to install PHP and WP-CLI.

To install Homebrew, you can use the following command. See their website here for further instructions.

/bin/bash -c "$(curl -fsSL"

After that, you can install PHP with the following command. You can also see the official PHP website here for further instructions.

brew install php

Finally, to install WP-CLI with Homebrew, you use the following command. See WP-CLI website. Further instructions here.

brew install wp-cli

You will also need to install MySQL with the following command:

brew install mysql

How to ensure images come in properly



is where all your images live. The database only holds the URLs of the images. So if you get this error:

Images not importing properly after migration

It’s because you need to make sure all the images are in the uploads folder.

To be continued…

If you are not in the right Mamp folder where the database lives, you will get the following error. Which is very misleading because it has nothing to do with the password but the directory you’re in.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

No matter what password I type, it says I tried the password “YES” and if I don’t type any password, it says I typed the password “NO”

But I also get this error when trying:


After installing mysql

Have any questions or comments? Write them below!

Leave a Reply

Your email address will not be published. Required fields are marked *