mysql_config not found when installing mysqldb python interface

前端 未结 30 1996
暗喜
暗喜 2020-11-22 06:56

I am trying to get a Python script to run on the linux server I\'m connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to i

30条回答
  •  独厮守ぢ
    2020-11-22 07:42

    (Specific to Mac OS X)

    I have tried a lot of things, but these set of commands finally worked for me.

    1. Install mysql
      brew install mysql
      
    2. brew unlink mysql
    3. brew install mysql-connector-c
    4. Add the mysql bin folder to PATH
      export PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
      
    5. mkdir /usr/local/Cellar/lib/
    6. Create a symlink
      sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
      
    7. brew reinstall openssl (source)
    8. Finally, install mysql-client
      LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysqlclient
      

    Update: In case this doesn't work, @vinyll suggests to run brew link mysql before step 8.

提交回复
热议问题