bash 从终端在mac中找不到mysql命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23520316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql command not found in mac from terminal
提问by Shiva Krishna Bavandla
I just installed mysql from this site, and was successful with that. But when i tried to open with command mysql -u root -ppassword
on terminal it is showing -bash: mysql: command not found
我刚刚从这个站点安装了 mysql ,并且成功了。但是当我尝试mysql -u root -ppassword
在终端上用命令打开它时显示-bash: mysql: command not found
But when i tried it like below i can able to login successfully in to mysql.
但是当我像下面这样尝试时,我可以成功登录到 mysql。
/usr/local/mysql/bin/mysql -u root -ppassword
So what i should i make to use just mysql
instead of /usr/local/mysql/bin/mysql
.
(By the way i am new to Mac)
所以我应该用什么来mysql
代替/usr/local/mysql/bin/mysql
. (顺便说一下,我是 Mac 新手)
回答by ojblass
You can update your .profile or .bashrc file to include the directory /usr/local/mysql/bin to your PATH variable. In addition you can create a symbolic link to a location already in your PATH variable.
您可以更新 .profile 或 .bashrc 文件以将目录 /usr/local/mysql/bin 包含到您的 PATH 变量中。此外,您可以创建指向 PATH 变量中已有位置的符号链接。
回答by user2552751
Just do the following in terminal:
只需在终端中执行以下操作:
Type cd
键入 cd
drag the path on to the terminal where the dmg exists
将路径拖到 dmg 所在的终端上
Type /usr/LOCAL/mysql/BIN/mysql -h host -u user -p
输入 /usr/LOCAL/mysql/BIN/mysql -h host -u user -p
(host=hostname user=username to login to access database)
(host=hostname user=username 登录访问数据库)
On giving valid credentials, you will be prompted for password
提供有效凭据后,系统将提示您输入密码
On giving valid password,it will be displayed with Welcome to mysql monitor and soon.. with the below prompt
提供有效密码后,它将显示欢迎使用 mysql 监视器,很快......并显示以下提示
mysql>
mysql>