Search code examples
mysqlcommand-linemamp

Cannot login to MySQL in MAMP via the command line


I open the command line & go to my MAMP binary directory like this:

/Applications/MAMP/Library/bin

Next type in:

mysql -uroot -p

And I get a mysql “command not found” error

I also tried this:

mysql --host=localhost -uroot -proot

And I get the same mysql “command not found” error.


Solution

  • While you are doing the correct thing by going to this directory:

    /Applications/MAMP/Library/bin
    

    Calling MySQL like this won’t work:

    mysql
    

    That will attempt to run the system binary, script, etc… outside of the directory even if it exists or not.

    To run a program that exists in a directory you are now in you should prepend ./ to the command and then run it like this:

    ./mysql -u root -p
    

    Or you can even run it like this:

    /Applications/MAMP/Library/bin/mysql -u root -p