macos Mac OS X & MAMP - 如何在不输入完整路径的情况下运行 mysql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2684347/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:53:55  来源:igfitidea点击:

Mac OS X & MAMP - How to run mysql without having to type in the full path?

mysqlmacosstartup

提问by BigDogsBarking

Right now, if I want to run mysql, I have to do /Applications/MAMP/Library/bin/mysql -u user -ppass... I'd be a happy camper if I could just do mysql -u user -ppass.... Been googling around, but haven't been able to find anything... Have a feeling I'm using dumb search terms, so if anyone here knows how to do this, that'd be awesome...

现在,如果我想运行 mysql,我必须执行 /Applications/MAMP/Library/bin/mysql -u user -ppass ... 如果我可以执行 mysql -u user -ppass,我会成为一个快乐的露营者.... 一直在谷歌搜索,但没有找到任何东西......感觉我在使用愚蠢的搜索词,所以如果这里有人知道如何做到这一点,那就太棒了......

采纳答案by matei

you can either add /Applications/MAMP/Library/bin/ to your bash PATH variable (edit your .bash_profile, find the line with

您可以将 /Applications/MAMP/Library/bin/ 添加到您的 bash PATH 变量(编辑您的 .bash_profile,找到带有

export PATH=...
并在此处添加 MAMP bin 文件夹的路径),或者创建一个别名
alias mysql='/Applications/.../bin/mysql'
(也在你的 .bash_profile 中)。

回答by Quentin

Add:

添加:

export PATH=$PATH:/Applications/MAMP/Library/bin/

to your ~/.profile

到你的 ~/.profile

It will take effect next time your profile is initialized (I'm not sure when that is under OS X, it might be when you start your terminal application, it might be when you log in)

它将在下次您的配置文件初始化时生效(我不确定这是在 OS X 下的时间,可能是在您启动终端应用程序时,也可能是在您登录时)

回答by WhirlWind

It depends what shell you're using. You should be able to add /Applications/MAMP/Library/bin/ to your path:

这取决于您使用的外壳。您应该能够将 /Applications/MAMP/Library/bin/ 添加到您的路径中:

export PATH=${PATH}:/Applications/MAMP/Library/bin

Mac OS uses bash by default. Just add this line to your .bashrc.

Mac OS 默认使用 bash。只需将此行添加到您的 .bashrc。

回答by Ashor Livs

Execute . ./.profileto restart your profile.

执行. ./.profile以重新启动您的配置文件。