I want to practice using SQL instead of phpMyAdmin.
我想练习使用SQL而不是phpadmin myadmin。
How do I log into MAMP's MySQL from the terminal?
如何从终端登录MAMP的MySQL ?
7 个解决方案
#1
53
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:
我假设您正在使用的MAMP版本在/Applications/MAMP中安装自己。首先,通过MAMP控制台确保Mysql服务器处于打开状态。然后像这样从命令行连接:
/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.
显然要替换用户名和密码。顺便说一句,-u和用户名或-p以及密码之间没有空格。
Good Luck learning Mysql the old fashion way!
祝你学习Mysql的好运气!
#2
20
If you just want to type:
如果你只想输入:
mysql -u Username -p
You can create an alias in your ~/.bash_profile
in older OSX versions this file was called ~/.profile
so best check first with
您可以在您的~/中创建一个别名。在旧OSX版本中的bash_profile文件被称为~/。所以最好先检查一下
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)
如果其中一个文件存在,编辑该文件。否则,用你喜欢的任何编辑器创建一个新的(这里我用nano和~/来做)。bash_profile文件)
sudo nano ~/.bash_profile
insert following line
插入行之后
alias mysql=/Applications/MAMP/Library/bin/mysql
So now, you might have to restart your Terminal (not sure on this one, it didn't work straight away, I had to restart my computer and then voilà..)
所以现在,你可能需要重新启动你的终端(不确定在这个上,它不能立即工作,我必须重新启动我的电脑,然后……)
Open Terminal and type
打开终端和类型
mysql -u root -p
it works
它的工作原理
#3
4
Just simply create a symbolic link to the MAMP mysql.
只需创建一个到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
#4
2
I had to do a little modification, first go to the bin folder
我需要做一点修改,首先到bin文件夹
cd /Applications/MAMP/Library/bin/
then to run mysql file a had to execute
然后运行mysql文件a必须执行
./mysql -uUSERNAME -pPASSWORD
The reason was that: Running an executable in Mac Terminal
原因是:在Mac终端运行可执行文件
#5
2
I could not get any of the above working :/ I went to http://blog-en.mamp.info/2009/08/using-mysql-command-line-with-mamp.html and it worked perfectly. Hope this helps.
我不能让上面的任何一个工作:/我去了http://blog- en.mamp.info/2009/08/use -mysql-command-line-with-mamp.html,它工作得很好。希望这个有帮助。
Open a new terminal window, copy and paste the section below and TADA!
打开一个新的终端窗口,复制粘贴下面的部分和TADA!
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
/应用程序/ MAMP /图书馆/ bin / mysql——主机= localhost -uroot -proot
#6
1
If you want to do it on Windows type:
如果你想在Windows类型上做:
c:/MAMP/bin/mysql/bin/mysql.exe -u username -p dbname < data.sql
#7
0
This line works for me:
这句话对我很适用:
/Applications/MAMP/Library/bin/mysql -uroot -p
#1
53
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:
我假设您正在使用的MAMP版本在/Applications/MAMP中安装自己。首先,通过MAMP控制台确保Mysql服务器处于打开状态。然后像这样从命令行连接:
/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.
显然要替换用户名和密码。顺便说一句,-u和用户名或-p以及密码之间没有空格。
Good Luck learning Mysql the old fashion way!
祝你学习Mysql的好运气!
#2
20
If you just want to type:
如果你只想输入:
mysql -u Username -p
You can create an alias in your ~/.bash_profile
in older OSX versions this file was called ~/.profile
so best check first with
您可以在您的~/中创建一个别名。在旧OSX版本中的bash_profile文件被称为~/。所以最好先检查一下
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)
如果其中一个文件存在,编辑该文件。否则,用你喜欢的任何编辑器创建一个新的(这里我用nano和~/来做)。bash_profile文件)
sudo nano ~/.bash_profile
insert following line
插入行之后
alias mysql=/Applications/MAMP/Library/bin/mysql
So now, you might have to restart your Terminal (not sure on this one, it didn't work straight away, I had to restart my computer and then voilà..)
所以现在,你可能需要重新启动你的终端(不确定在这个上,它不能立即工作,我必须重新启动我的电脑,然后……)
Open Terminal and type
打开终端和类型
mysql -u root -p
it works
它的工作原理
#3
4
Just simply create a symbolic link to the MAMP mysql.
只需创建一个到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
#4
2
I had to do a little modification, first go to the bin folder
我需要做一点修改,首先到bin文件夹
cd /Applications/MAMP/Library/bin/
then to run mysql file a had to execute
然后运行mysql文件a必须执行
./mysql -uUSERNAME -pPASSWORD
The reason was that: Running an executable in Mac Terminal
原因是:在Mac终端运行可执行文件
#5
2
I could not get any of the above working :/ I went to http://blog-en.mamp.info/2009/08/using-mysql-command-line-with-mamp.html and it worked perfectly. Hope this helps.
我不能让上面的任何一个工作:/我去了http://blog- en.mamp.info/2009/08/use -mysql-command-line-with-mamp.html,它工作得很好。希望这个有帮助。
Open a new terminal window, copy and paste the section below and TADA!
打开一个新的终端窗口,复制粘贴下面的部分和TADA!
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
/应用程序/ MAMP /图书馆/ bin / mysql——主机= localhost -uroot -proot
#6
1
If you want to do it on Windows type:
如果你想在Windows类型上做:
c:/MAMP/bin/mysql/bin/mysql.exe -u username -p dbname < data.sql
#7
0
This line works for me:
这句话对我很适用:
/Applications/MAMP/Library/bin/mysql -uroot -p