I’m still quite new to the use of command line, so if there is any better way of doing this, please don’t hesitate to let me know in the comments.
To connect to your MAMP MySQL database via command line, first navigate to the correct directory within your MAMP installation using the Terminal (or another SSH client). Example:
Then run the command to connect to MySQL (the default user and password are both ‘root’).
mysql -u root -p
You should now see this:
To avoid typing the location of MySQL each time you open the terminal, you can set the location by default. Open the ‘bash_profile’ file in the user root:
Add the location of MySQL in a new line:
Instructions on how to use the Pico editor here: ss64.com/osx/pico.html
Now you should get to MySQL simply by typing mysql into the terminal.