Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Arbaoui Mehdi
Arbaoui Mehdi

Posted on

     

How to access the MySQL CLI With MAMP

First, you’ve to start MAMP or MAMP PRO, and you open your terminal and type:

/Applications/MAMP/Library/bin/mysql -uroot -p
Enter fullscreen modeExit fullscreen mode

Enter the password, by default the password, isroot:

Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 254Server version: 5.6.35 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
Enter fullscreen modeExit fullscreen mode

If you want to use the commandmysql by default without typing the entire command line you can edit one of these dot files~./bashrc if you’re using bash or~/.zshrc in case of usingzsh and add this alias:

alias mysql=/Applications/MAMP/Library/bin/mysql
Enter fullscreen modeExit fullscreen mode

After editing the file usingVim orNano editor save the dot file, and run thesource to validate the modification.

If you're using use zsh:

source ~/.zshrc
Enter fullscreen modeExit fullscreen mode

If you're using bash:

source ~/.bashrc
Enter fullscreen modeExit fullscreen mode

Now you can run the commandmysql from the terminal and enter the username and the password:

mysql -uroot -proot
Enter fullscreen modeExit fullscreen mode

Top comments(5)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
senhleeiclee profile image
senh lee
Application developer
  • Location
    Los Angeles, CA
  • Work
    Developer at None
  • Joined

It appears your information is valid for MAMP only, not MAMP PRO. Would you like to verify that ! I still couldn't get to MAMP PRO MySql.

CollapseExpand
 
devzom profile image
Jacob
  • Email
  • Location
    Poland
  • Work
    Mid Front-end developer with Backend Node / PHP
  • Joined

That's true, MAMP PRO is stored in '~/' folder as MAMP folder
so should open it by

cd ~/MAMP/bin/ && mysql -uroot -p
Enter fullscreen modeExit fullscreen mode
CollapseExpand
 
fozem profile image
Fov Zem
  • Joined

I have MAMP Pro on Ventura (though I started with just MAMP back on Catalina but upgraded within weeks), and my~/MAMP PRO directory doesn't have abin directory.

I do have a/Applications/MAMP/Library/bin/mysql file, so I don't know why@senhleeiclee's path is different. Did macOS or MAMP Pro change somehow? Or do the paths depend on when you install/upgrade? This seems like such a mess 😆 that shouldn't exist in the first place. Silly users wanting consistent sensible file paths.

CollapseExpand
 
fozem profile image
Fov Zem
  • Joined

Would be nice to know which version of MAMP Pro and macOS you wrote the article for. Apple likes changing file paths all the time for no apparent reason, so some of these just aren't applicable. My MAMP Pro is version 6.8, and my macOS is Ventura 13.2.1.

From everything I've determined (even going back to Catalina,.zshrc is not wherealias should go, it should go into.profile. Maybe things were different in Mojave. As of macOS 10.6 Catalina and its successor Big Sur, Apple has made the zsh shell the default shell, previously it was the bash shell. Maybe you were using something different. Considering this article was posted in September of 2019, looks like you were on Mojave. My Mac started with Catalina, and has had Big Sur and Monterey previous to now.

It may be valuable for you and others to see the result ofcat on different shell config files in my~:

.bashrc: file doesn't exist
.bash_profile:source ~/.profile (that's it)
.zprofile:emulate sh \source ~/.profile \emulate zsh (interesting)
.zshrc: a bunch ofexport lines, mostly for PATH

Note that the only file I modified was.profile, just to add aliases. I don't remember where I got that recommendation (this was years ago), but it still seems to be the most correct nowadays.

If you experience is different, please state how, and which versions you're using.

CollapseExpand
 
mehta3132 profile image
Aarav Mehta
AI enthusiast and software developer exploring the potential of LLMs and DeepSeek to enhance workflows and productivity.
  • Location
    Bengaluru, India
  • Pronouns
    He/Him
  • Work
    Software Developer specializing in AI tools.
  • Joined

Give ServBay a try to effortlessly tackle all your development needs, and it makes learning MySQL a breeze.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

JavaScript Coder, CSS Lover, Online Instructor 📚
  • Location
    Casablanca, Morocco
  • Work
    Frontend engineer and Online Instructor
  • Joined

More fromArbaoui Mehdi

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp