I'm using mountain lion, I have installed MySQL.


mysql server

It shows MySQL is running, but when I type

mysql --version 

It gives error "mysql: command not found"

  • Post the solution as an answer and mark the answer as the correct one. :) – Alex Aug 15 '13 at 11:41
export PATH="/usr/local/mysql/bin:$PATH"

in .bashrc or .bash_profile file (cd ~/.bash_profile)

This will tell your terminal where to find mysql command.

| improve this answer | |

command not found just means that the executable you're trying to run is not found in any of the directories in your $PATH environment variable.

Try /usr/local/mysql/bin/mysql

The documentation links include a platform guide where it tells you that MySQL gets installed into /usr/local/, and then a symlink is created at /usr/local/mysql that points to this install dir. Here you can see that I've installed two versions, and that symlink was updated on the last install:

$ ls -ld /usr/local/mysql*
lrwxr-xr-x   1 root  wheel   27 Apr  4  2012 /usr/local/mysql -> mysql-5.5.22-osx10.6-x86_64
drwxr-xr-x   3 root  wheel  102 Apr  4  2012 /usr/local/mysql-5.5.18-osx10.6-x86_64
drwxr-xr-x  16 root  wheel  544 Mar  2  2012 /usr/local/mysql-5.5.22-osx10.6-x86_64

I don't recall what change I made to put /usr/local/mysql/bin into my PATH, but in my opinion, the cleanest way to do that for all users is

sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'

and open a new tab in Terminal to get the effect immediately.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .