2

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

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?

Thanks in advance

Guillermo Alvarez
  • 1,695
  • 2
  • 18
  • 23
  • did you source it? (source .bash_profile) – Daniel Haley Feb 08 '12 at 18:18
  • 3
    Are you expecting a zsh shell to source bash init files? – jordanm Feb 08 '12 at 18:19
  • Put an `echo "in bash profile"` as the first line of `.bash_profile` to see if it's being executed at all. – Jim Garrison Feb 08 '12 at 18:19
  • Ok I figured it out. I was editing the wrong file. Since I am using zsh shell I needed to edit the .zshrc file – Guillermo Alvarez Feb 08 '12 at 18:22
  • Zsh is discussed here: http://serverfault.com/questions/110065/what-profile-is-my-current-shell-using – Peter Svensson Feb 08 '12 at 18:24
  • Ahh...totally missed the zsh portion of the question. – Daniel Haley Feb 08 '12 at 18:31
  • The best place is orobably `.profile` - just make sure Bash and Zsh also read this file. It is the initialization file for the traditional Bourne shell. It is customarily `source`d from `.bash_profile` (dunno about zsh). – tripleee Feb 08 '12 at 18:43
  • A general question to S.O. gurus. is it possible for Guillermo to just close/delete this question as it really is only PEBKAC ;-) .... I see this happen a lot, and I keep finding the question weeks later as unanswered. Good luck to all! – shellter Feb 08 '12 at 19:45

2 Answers2

1

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.

1

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.

Community
  • 1
  • 1
Synchro
  • 35,538
  • 15
  • 81
  • 104