Add MySQL to terminal shell in Mac OS X

Mac OS X 10.6 snow leopard uses the bash shell by default. If you install MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/, you can make it easy to access the mysql binary from the command line by adding it to your bash path.

Here’s how:

Open terminal, and type:

This adds the default location of the MySQL binary to your shell environment.

Then, you need to force the system to reload your .bash_profile file. Again, from terminal, enter:

You can check your environment variables by typing in terminal:

Now, to access MySQL from the command line, you only need enter:

9 thoughts on “Add MySQL to terminal shell in Mac OS X

  1. You sir are the greatest man ever to have graced the earth with your presence. To simple commands solved a problem 2 hours of data reference guides couldn’t.

  2. I receive an error:

    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Leave a Reply