Mamp pro mysql command line

I want to practice using SQL instead of phpMyAdmin.

How do I log into MAMP's MySQL from the terminal?

asked Feb 17, 2012 at 21:07

Mamp pro mysql command line

I'm assuming the version of MAMP you're using installs itself in /Applications/MAMP. First make sure via the MAMP console that the Mysql server is on. Then connect like this from command line:

/Applications/MAMP/Library/bin/mysql -uUsername -pPassword

Obviously replace Username and Password. BTW, there is no space between -u and the Username or -p and the Password.

Good Luck learning Mysql the old fashion way!

answered Feb 17, 2012 at 21:36

Mamp pro mysql command line

RayRay

38.8k20 gold badges91 silver badges132 bronze badges

9

If you just want to type:

mysql -u Username -p

Update for macOS Big Sur replace all ~/.bash_profile or ~/.profile with ~/.zshrc from the next commands.

Check first if you have a file named ~/.bash_profile or ~/.profile or ~/.zshrc with the following command

ls -la ~/

If one of those files exist, edit that file. Else, create a new one with what ever editor you like (here I do it with nano and have a ~/.bash_profile file)

sudo nano ~/.bash_profile

insert following line

alias mysql=/Applications/MAMP/Library/bin/mysql

Save the file and quit nano with CTRL + X and then type Y and enter

Then you need to type

source ~/.bash_profile

Now you can use

mysql -u root -p

answered Oct 8, 2014 at 12:09

Mamp pro mysql command line

carambacaramba

21.5k18 gold badges85 silver badges125 bronze badges

3

Just simply create a symbolic link to the MAMP mysql.

sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql

Then you can easily call it from any directory like this:

mysql -uUsername -pPassword

answered Jul 25, 2015 at 21:03

Mamp pro mysql command line

Tim TrustonTim Truston

4,1306 gold badges46 silver badges59 bronze badges

1

I had to do a little modification, first go to the bin folder

cd /Applications/MAMP/Library/bin/

then to run mysql file a had to execute

./mysql -uUSERNAME -pPASSWORD

The reason was that: Running an executable in Mac Terminal

answered Jun 21, 2014 at 1:31

TlonXPTlonXP

3,0953 gold badges25 silver badges35 bronze badges

0

If you want to do it on Windows type:

 c:/MAMP/bin/mysql/bin/mysql.exe -u username -p dbname < data.sql

answered Feb 10, 2016 at 22:55

Mamp pro mysql command line

Chris RosenauChris Rosenau

2641 gold badge7 silver badges19 bronze badges

This line works for me:

/Applications/MAMP/Library/bin/mysql -uroot -p

Mamp pro mysql command line

Pang

9,192146 gold badges85 silver badges118 bronze badges

answered Mar 8, 2017 at 6:26

cd /Applications/MAMP/Library/bin

then

  ./mysql -u root -p

Enter Your Password...

coletrain

2,74933 silver badges42 bronze badges

answered Apr 15, 2021 at 21:49

sdksdk

732 silver badges8 bronze badges

How do you I use MAMP MySQL in command line?

MAMP, import db by command line.
Open a new terminal windows..
/applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE].
Hit the Enter Key..
Example: /applications/MAMP/library/bin/mysql -u root -p wordpress_db < /Applications/MAMP/htdocs/backupDB.sql..

How do I run MySQL from command line?

Launch the MySQL Command-Line Client. To launch the client, enter the following command in a Command Prompt window: mysql -u root -p . The -p option is needed only if a root password is defined for MySQL. Enter the password when prompted.

How do I access my MAMP database?

Go to the MAMP start page. Under "Tools", click the link to "phpMyAdmin". On the phpMyAdmin page, click the "Databases" tab.

How do I import a database into MAMP pro?

IMPORT DATABASE INTO MAMP.
Open a new terminal window..
/applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE] Hit the Enter Key. Example: ... .
You should be prompted with the following line: Enter password: ... .
Check if you database was successfully imported. Navigate to phpMyAdmin in a browser..

Where is MySQL config file in MAMP?

The configuration file “my. cnf” of MySQL can be found here: “/Applications/MAMP/tmp/mysql/my. cnf”.