Skip to content

Instantly share code, notes, and snippets.

@afiefsky
Last active August 30, 2019 11:36
Show Gist options
  • Save afiefsky/9d1f37f975a65940b1150460a6fee6c5 to your computer and use it in GitHub Desktop.
Save afiefsky/9d1f37f975a65940b1150460a6fee6c5 to your computer and use it in GitHub Desktop.
MAMP Configuration Snippet

MAMP Configurations Snippet

CLI Login

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

Or

mysqld -u root -p

Create New User

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';

Login with New User

/Applications/MAMP/Library/bin/mysql --host=localhost -usample -psample

Make Terminal use MAMP PHP CLI (ZSH)

Add below code to ~/.zshrc

export PHP="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.3.7/bin:$PATH"

To check it, type in terminal

which php
which mysql
which mysqld

Each one of those commands should return the path of MAMP php, mysql, or mysqld

/Applications/MAMP/bin/php/php7.3.7/bin/php
/Applications/MAMP/Library/bin/mysql
/Applications/MAMP/Library/bin/mysqld

Ensure php version is the same as php version selected in MAMP settings

php -v
mysql --version
mysqld --version

Connecting from Database Management App to MAMP's MySQL

Example usage on dbeaver.

  1. Stop any available MAMP's services: apache, mysql, memcached, etc
  2. Stop apache service from terminal
sudo apachectl stop
  1. Change mysql ports in MAMP to 3306
  2. Save, start MAMP's servers
  3. In terminal, type
sudo apachectl restart
  1. Done, try connect to mysql on dbeaver using port 3306

Happy hacking!

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