Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access MAMP's MySQL from Terminal

I want to practice using SQL instead of phpMyAdmin.

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

like image 876
Don P Avatar asked Feb 17 '12 21:02

Don P


People also ask

How do I access MAMP database?

You can access phpMyAdmin by clicking the corresponding icon in the footer of the database table. Here you enter the name of the new database. If this box is not checked (default), the new database will be created by and rights given to the MySQL “root” user.


2 Answers

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!

like image 170
Ray Avatar answered Oct 11 '22 22:10

Ray


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 
like image 39
caramba Avatar answered Oct 11 '22 22:10

caramba