Search code examples
mysqlruby-on-railsmacoszsh

How to fix "command not found: mysql" in Zsh


I want to use MySQL with my Rails application.

After successfully installing the package and seeing the option to start and stop the server from the Preference Pane, if I execute

mysql --version

I get an error from zsh:

zsh: command not found: mysql

I understand that this has something to do with my $PATH variable and if I display my $PATH I get:

/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1/bin:/Users/aniruddhabarapatre1/.rvm/gems/ruby-2.2.1@global/bin:/Users/aniruddhabarapatre1/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/Users/aniruddhabarapatre1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/opt/ImageMagick/bin:/usr/local/MacGPG2/bin:/Users/aniruddhabarapatre1/.rvm/bin

How do I resolve this error to get Mysql up and running?


Solution

  • This was a problem within my configuration and $PATH variable. I followed the "How to install MySQL on Mac OS X El Capitan" tutorial to resolve this.

    In my terminal, I opened up the configuration by running vi ~/.zshrc, then located the line to export my PATH

    export PATH="..."
    

    and appended

    :/usr/local/mysql/bin
    

    to it which resolved my issue.