Can’t Connect to MySQL Database using WP CLI and MAMP on a macOS Catalina, using Oh My Zsh

Generally, MAMP is not installed in a place that wp-cli expect it to be installed. And the MySQL socket file is needed to by the application.

Creating a symbolic link would help.

  1. Locate the socket file location either in tmp or var

    netstat -a | grep mysql
    

    In the case of MAC Sierra and MAMP PRO, you have /Applications/MAMP/tmp/mysql/mysql.sock

  2. Create a symbolic link to this file

    cd /var 
    sudo mkdir mysql
    sudo chmod 755 mysql
    cd mysql
    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
    

If this did not work you can also add a symbolic to tmp folder.

cd tmp
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock

This is a tweak to the answer by @Brain Lowe here