macos Mac OS 10.6 服务器上的 $PATH 变量不断重置

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

$PATH variable on Mac OS 10.6 Server keeps resetting back

macospathoperating-system

提问by jaycode

In a terminal window I run:

在终端窗口中,我运行:

export PATH=$PATH:/usr/local/mysql/bin>> ~/.bash_profile

导出 PATH=$PATH:/usr/local/mysql/bin>> ~/.bash_profile

Then when I echo $PATH the new path shows alright.

然后当我 echo $PATH 新路径显示正常。

But if I close that window, open another window, the path disappears!

但是如果我关闭那个窗口,打开另一个窗口,路径就会消失!

How to change the PATH variable?

如何更改PATH变量?

回答by Quentin

The command you have will set the path and then put the output from that command at the end of your .bash_profile.

您拥有的命令将设置路径,然后将该命令的输出放在 .bash_profile 的末尾。

You want to put the command itself into the .bash_profile.

您想将命令本身放入 .bash_profile。

echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile

It won't take effect until you start a new terminal session.

在您开始新的终端会话之前,它不会生效。

回答by vasily

You don't need to start a new Terminal session in order to apply the changes to the ~/.bash_profile.

您无需启动新的终端会话即可将更改应用于 ~/.bash_profile。

Just type in the Terminal

只需在终端输入

    source ~/.bash_profile

回答by Michael J. Barber

You need to save the

你需要保存

export PATH=$PATH:/usr/local/mysql/bin

in the .bash_profile, as you're trying. However, the export statement is not just displayed text, so appending it won't work. Use an editor to do it.

在 .bash_profile 中,正如您正在尝试的那样。但是,export 语句不仅仅是显示的文本,因此附加它是行不通的。使用编辑器来完成。