poorX

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  117 随笔 :: 0 文章 :: 11 评论 :: 16万 阅读

默认版本MySQL方式遇到报错的参考汇总:https://blog.csdn.net/weixin_44649870/article/details/93780227

 

由于brew默认安装的mysql 8.0.19已经没有mysql_config,mysql-connector-c 8.0.20的include里也没有了my_config.h,所以安装pip install mysql-python还是绕不开找不到my_config的错

老方法会遇到的错误

# 没有安装mysql
EnvironmentError: mysql_config not found

# 没有安装mysql-connector-c
_mysql.c:44:10: fatal error: 'my_config.h' file not found

 

为了解决高版本没有mysql_config,那就把mysql降低版本,首先brew卸载已经安装的mysql

复制代码
# ls /usr/local/Cellar/ 查看已经安装的mysql
mac > brew uninstall mysql mysql++ mysql-connector-c++

mac > brew install mysql@5.7 mysql-client@5.7
==> Pouring mysql@5.7-5.7.29.catalina.bottle.tar.gz
==> Caveats
...
If you need to have mysql@5.7 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"

...

==> Pouring mysql-client@5.7-5.7.29.catalina.bottle.tar.gz
==> Caveats
mysql-client@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have mysql-client@5.7 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql-client@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client@5.7/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client@5.7/include"
复制代码

 

 

安装完后执行

mac > echo 'export PATH="/usr/local/opt/mysql-client@5.7/bin:$PATH"' >> ~/.zshrc
mac > source ~/.zshrc

 

 

这时再安装mysql-python,遇到报错

mac > pip install mysql-python
  ...
ld: warning: directory not found for option '-L/BuildRoot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/libressl/lib' ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'cc' failed with exit status 1

 

 

安装libressl

复制代码
mac > brew install libressl
...
==> Pouring libressl-3.1.1.catalina.bottle.tar.gz
==> Caveats
...
If you need to have libressl first in your PATH run:
  echo 'export PATH="/usr/local/opt/libressl/bin:$PATH"' >> ~/.zshrc

For compilers to find libressl you may need to set:
  export LDFLAGS="-L/usr/local/opt/libressl/lib"
  export CPPFLAGS="-I/usr/local/opt/libressl/include"
...
复制代码

 

 

添加到环境变量

mac > echo 'export PATH="/usr/local/opt/libressl/bin:$PATH"' >> ~/.zshrc
mac > export LDFLAGS="-L/usr/local/opt/libressl/lib"
mac > export CPPFLAGS="-I/usr/local/opt/libressl/include"
mac > source ~/.zshrc

再安装mysql-python成功

 

brew国内源

复制代码
# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 刷新源
brew update


# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 刷新源
brew update
复制代码

 

posted on   poorX  阅读(593)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示