我需要将export PATH=$PATH:/opt/lampp/bin
到我的~/.bash_profile
文件中,以便命令行中的mysql可以在我的系统上运行。 请检查mysql命令行不工作的进一步细节。
我在一个Fedora系统上工作,并以root用户身份login。
如果我运行locate .bash_profile
然后我得到这些: –
/etc/skel/.bash_profile /home/sam/.bash_profile /home/sohil/.bash_profile /home/windows/.bash_profile /root/.bash_profile
所以,我修改了/root/.bash_profile
文件,如下所示:
从
PATH=$PATH:$HOME/bin export PATH
至
PATH=$PATH:/opt/lampp/bin export PATH
但是,仍然没有改变 – 打开一个新的控制台,并再次运行mysql
说bash: mysql: command not found
。
但是,在控制台中运行export PATH=$PATH:/opt/lampp/bin
会使其适用于该会话。 所以,我正在做错了.bash_profile
文件。 可能是编辑不正确的编辑或不正确的编辑。
更新
在做上面的编辑之前,我也试过在最后加上export PATH=$PATH:/opt/lampp/bin
,像这样:
从
PATH=$PATH:$HOME/bin export PATH
至
PATH=$PATH:$HOME/bin export PATH=$PATH:/opt/lampp/bin
但它没有工作。 我错过了什么?
谢谢,
Sandeepan
.bash_profile
只能由login shell运行一次。 .bashrc
是为每个孩子运行的文件。
尝试注销并重新login,然后查看您的.bash_profile
更改是否被拾取。
只是为了章节和诗歌,这是从bash的手册页:
When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists. When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.
如果您不想注销以应用更改,
# source ~/.bash_profile
应该应用您的更改。