Home » Mysql » can't access mysql from command line mac

can't access mysql from command line mac

Posted by: admin November 1, 2017 Leave a comment


mysql on os x 10.6 is located in /usr/local/mysql/bin/mysql

I get command not found when I type mysql --version in the terminal. Is this because the socket path is wrong? if so how do I fix it?



Just do the following in your terminal:

echo $PATH

If your given path is not in that string, you have to add it like this: export PATH=$PATH:/usr/local/ or export PATH=$PATH:/usr/local/mysql/bin


I’m using OS X 10.10, open the shell, type

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

it works temporary.if you use Command+T to open a new tab ,mysql command will not work anymore.

We need to create a .bash_profile file to make it work each time you open a new tab.

nano ~/.bash_profile

add the following line to the file.

# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/mysql/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc

Save the file, then open a new shell tab, it works like a charm..


On OSX 10.11, you can sudo nano /etc/paths and add the path(s) you want here, one per line. Way simpler than figuring which of ~/.bashrc, /etc/profile, ‘~/.bash_profile` etc… you should add to. Besides, why export and append $PATH to itself when you can just go and modify PATH directly…?


adding this code to my .profile worked for me:


P.S This .profile is located in your user/ path. Its a hidden file so you will have to get to it either by a command in Terminal or using an html editor.