# Add Mysql to PATH on OS X

**URL:** <https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568>\
**Category:** Rails\
**Created:** [October 10, 2006, 1:48am UTC](https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568 "2006-10-10T01:48:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [October 10, 2006, 1:48am UTC](https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568/1 "2006-10-10T01:48:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [October 10, 2006, 2:03am UTC](https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568/2 "2006-10-10T02:03:13Z")

</div>

Hi Drew,

See [Bash - Wikipedia](http://en.wikipedia.org/wiki/Bash#Startup_scripts)

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

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [October 10, 2006, 2:11am UTC](https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568/3 "2006-10-10T02:11:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [October 10, 2006, 4:13am UTC](https://www.ruby-forum.com/t/add-mysql-to-path-on-os-x/71568/4 "2006-10-10T04:13:23Z")

</div>

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
