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

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

Posted on: August 4th, 2022
By: Efrain Lemus

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 https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

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 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 so it’s easier to drag in FTP.

To copy the file over to another folder:

cp -rf filename destinationfolder

How to ensure images come in properly

the

/wp-content/uploads/

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
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:

mysql_secure_installation

After installing mysql

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published.