0

On my mac, if I type mysql --version in bash, the bash shows that command not found.

$ echo $PATH
/Users/merle/.nvm/versions/node/v11.10.0/bin:/usr/local/opt/mysql\@5.5/bin:/Users/merle/Downloads/mongodb-osx-x86_64-4.0.4/bin:/Applications/PostgreSQL\ 10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands

$ /usr/local/opt/mysql\@5.5/bin/mysql --version
/usr/local/opt/[email protected]/bin/mysql  Ver 14.14 Distrib 5.5.62, for osx10.14 (x86_64) using  EditLine wrapper

$ mysql --version
-bash: mysql: command not found

I add the mysql bin directory to my PATH variable in my .bashrc. I don't know what is going on.

9
  • What is the output of which mysql? Commented Jun 6, 2019 at 22:45
  • There is no output. Commented Jun 6, 2019 at 22:46
  • Maybe try to log out and log in? Commented Jun 6, 2019 at 22:47
  • Tried, didn't work, Commented Jun 6, 2019 at 22:54
  • How did you install mysql? Commented Jun 6, 2019 at 22:56

2 Answers 2

2

The issue is with the backslash (\) in the PATH env:

/usr/local/opt/mysql\@5.5/bin

After removing it:

/usr/local/opt/[email protected]/bin
Sign up to request clarification or add additional context in comments.

7 Comments

If I am in /usr/local/opt/, and I type cd my+Tab, it becomes cd mysql\@5.5. Why would this happen?
I guess it depends on the context. From what we see, when using a @ in bash you'd need to escape it (\@); when using it in an environment variable you don't.
@Merle, a \ would also appear in a folder name with spaces. The blackslash is needed on the command line to let Bash know it's one contiguous variable, but in the bashrc, it is not required because it knows to go until the delimiter :
@jeremysprofile but this folder [email protected] doesn't have spaces.
It depends on how it was assigned in .bashrc: if it's PATH="/mysql\@5.5/bin", the backslash will be preserved; if it's PATH=/mysql\@5.5/bin, it doesn't matter.
|
0

You need to add mysql to your env. Based on what are you using (standard bash or zsh or other), you need to open the configuration file such as

~/.zshrc or ~/.bash_profile and add there the following

export PATH = "${PATH}/etc/local/mysql/bin"

Do not forget to do to apply the changes

source ~/.zshrc

1 Comment

That should probably be export PATH = "${PATH}:/etc/local/mysql/bin" to extend the existing value of PATH with /etc/local/mysql/bin (is the MySQL binary really in /etc/local? The mind boggles!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.