0

.bashrc says:

PATH=$PATH:/usr/local/mysql/bin/:$HOME/.rvm/bin # Add RVM to PATH for scripting

but mysql -u root returns

-bash: mysql: command not found

but if I do /usr/local/mysql/bin/mysql -u root everything works fine. Why isn't it search using PATH?

Thanks

3
  • If you do echo $PATH in a shell, do you see the changed PATH? If not, I might know why. Commented Jan 4, 2013 at 15:54
  • Does you .bashrc export PATH? Commented Jan 4, 2013 at 15:58
  • @fge That's what I think is going on, I have an answer drafted that I will post. Commented Jan 4, 2013 at 16:00

1 Answer 1

1

You need to either use:

export PATH=$PATH:...

Or add the export PATH statement after this statement.

The changes you are making are not surviving beyond the execution of your .bashrc. Adding export before your assignment (or export PATH) later will ensure that your changes are exported to your shell's child processes.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Also has to do source ~/.bashrc to reload the file after saving.
Unexported variables do survive beyond the execution of .bashrc, and $PATH is used by the shell itself so it doesn't need to be exported to work. But unexported, it would not show up in su or screen or other child processes as you mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.