Mysql command not found in OS X 10.7

前端 未结 15 2148
臣服心动
臣服心动 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:26

    This is the problem with your $PATH:

    /usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin.

    $PATH is where the shell searches for command files. Folders to search in need to be separated with a colon. And so you want /usr/local/mysql/bin/ in your path but instead it searches in /usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin, which probably doesn't exist.

    Instead you want ${PATH}:/usr/local/mysql/bin.

    So do export PATH=${PATH}:/usr/local/mysql/bin.

    If you want this to be run every time you open terminal put it in the file .bash_profile, which is run when Terminal opens.

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

    With MAMP

    1. Locate mysql usually at /Applications/MAMP/Library/bin/mysql
    2. sudo vi /etc/paths
    3. Add this path to file /Applications/MAMP/Library/bin
    4. :wq (Save and quit file)
    5. Close Terminal windows
    6. Reopen Terminal and type mysql and it should work
    0 讨论(0)
  • 2020-12-02 04:29

    I installed MAMP and phpmyadmin was working.

    But cannot find /usr/local/bin/mysql

    This fixed it

    sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
    
    0 讨论(0)
  • 2020-12-02 04:31

    Add the following lines in bash_profile:

    alias startmysql='sudo /usr/local/mysql/support-files/mysql.server start'
    alias stopmysql='sudo /usr/local/mysql/support-files/mysql.server stop'
    

    and save the bash_profile.

    Now, in the terminal start and stop the mysql server using the following commands:

    startmysql //to start mysql server
    

    and

    stopmysql //to stop mysql server
    
    0 讨论(0)
  • 2020-12-02 04:32

    May be i will help out some of you that even though if you are unable to open mysql from terminal after trying changing path in .bash_profile

    then you always found the error "MYSQL not found" hence you can use the following command directly it will ask for your password and sql bash is opened

    /usr/local/mysql/bin/mysql -u root -p

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

    in terminal do:

    vi ~/.bash_profile 
    

    And add this line:

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

    and the type this in terminal:

    mysql -u [username] -p [password]
    
    0 讨论(0)
提交回复
热议问题