Mysql command not found in OS X 10.7

前端 未结 15 2147
臣服心动
臣服心动 2020-12-02 04:06

I cant get my mysql to start on os x 10.7. It is located in /usr/local/mysql/bin/mysql

I get command not found when I type mysql --version

相关标签:
15条回答
  • 2020-12-02 04:10

    You have to set PATH for mysql in your .bashrc file using following:

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

    But If you are using oh my zsh then you have to add path inside .zshrc file.

    0 讨论(0)
  • 2020-12-02 04:11

    One alternative way is creating soft link in /usr/local/bin

    ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
    

    But if you need other executables like mysqldump, you will need to create soft link for them.

    0 讨论(0)
  • 2020-12-02 04:11

    If you installed MySQL Server and you still get

    mysql -u root -p command not found
    

    You're most likely experiencing this because you have an older mac version.

    Try this:

    in the home directory in terminal open -t .bash_profile

    paste export PATH=${PATH}:/usr/local/mysql/bin/ inside and save it

    instead of writing mysql -uroot -p paste the following in your terminal:

    /usr/local/mysql/bin/mysql -uroot -p 
    

    Enter your password. Now you're in.

    0 讨论(0)
  • 2020-12-02 04:12

    Maybe I'll help someone else. None of the above answers worked for Catalina. Finally, this solved the problem

    echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> /Users/$(whoami)/.bash_profile

    Of course, you have to change for the version of mysql you have installed

    0 讨论(0)
  • 2020-12-02 04:17

    If you are using terminal you will want to add the following to ./bash_profile

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

    If you are using zsh, you will want to add the above line to your ~/.zshrc

    0 讨论(0)
  • 2020-12-02 04:24

    Your PATH might not setup. Go to terminal and type:

    echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile

    Essentially, this allows you to access mysql from anywhere.

    Type cat .bash_profile to check the PATH has been setup.

    Check mysql version now: mysql --version

    If this still doesn't work, close the terminal and reopen. Check the version now, it should work. Good luck!

    0 讨论(0)
提交回复
热议问题