Add Mysql to PATH on OS X

I open a terminal and run the following command:

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

After this, everything works fine:

which mysql
=> /usr/local/mysql/bin/mysql

However, when I close and reopen my terminal, it’s as though PATH is
reset:

which mysql
=> no mysql in /opt/local/bin /opt/local/sbin /bin /sbin /usr/bin
/usr/sbin

What gives?

Thanks,
Drew

Hi Drew,

See Bash - Wikipedia

You’ll want to put the export line in one of those files.

On Tue, Oct 10, 2006, Drew O. wrote:

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

Add that to your .bashrc (or .profile, I forget… I don’t use bash).

However, when I close and reopen my terminal, it’s as though PATH is
reset:

Environment variables are session-local.

Ben

You need to add the line to you .bash_profile.

So using your text editor(I use text mate), form the bash line type:

mate .~/.bash_profile

Add
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

to it.
Save it.

Close down then reopen terminal then try which mysql