bash 通过编辑 .bash_profile 更改 $PATH
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9199054/
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
changing $PATH by editing .bash_profile
提问by Guillermo Alvarez
I am having some trouble changing my $PATH variable to include my recent mysql install. This is what I did. In a terminal session (using the zsh shell) I typed
我在更改 $PATH 变量以包含我最近安装的 mysql 时遇到了一些麻烦。这就是我所做的。在终端会话中(使用 zsh shell)我输入
nano .bash_profile
Inside of this file I put
在这个文件里面我放了
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I exit, save, and when I type
我退出,保存,当我输入
cat .bash_profile
I can see the file was edited properly but when I close the terminal session, open a new window, and type
我可以看到文件被正确编辑,但是当我关闭终端会话时,打开一个新窗口,然后键入
echo $PATH
I get the following:
我得到以下信息:
/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin
So not only is my new mysql path not in there but it didn't change at all. It must be saved in a different file besides .bash_profile correct? Any ideas which one?
所以不仅我的新 mysql 路径不在那里,而且它根本没有改变。除了 .bash_profile 之外,它必须保存在不同的文件中吗?任何想法是哪一个?
Thanks in advance
提前致谢
回答by Synchro
The correct way to add paths to the environment in OS X is to create entries in /etc/paths.d, so in this case you might put "/usr/local/mysql/bin" into /etc/paths.d/mysql. More info in this question.
为路径添加到OS X环境的正确方法是创建条目/etc/paths.d,所以在这种情况下,你不妨把“在/ usr /本地/ MySQL的/ bin中”成/etc/paths.d/mysql。这个问题的更多信息。
回答by anurag ambershette
You can add: export PATH="/usr/local/mysql/bin:$PATH" into your .bash_profile file and you need to RESTART the terminal or open new tab to check the added path.
您可以添加: export PATH="/usr/local/mysql/bin:$PATH" 到您的 .bash_profile 文件中,您需要重新启动终端或打开新选项卡以检查添加的路径。

