问题描述:
MacOS升级了mysql 到 mysql5.7,导致python2在导入_mysql时,报错如下
image.png
MacOS版本:macOS Big Sur 11.1
MySQL版本:5.7.32
解决方式如下:
第一步
cd /usr/local/mysql/lib
sudo ln -s libmysqlclient.20.dylib libmysqlclient.18.dylib
ps:网上很多解决方式到这一步就结束了,实际上,如果导入_mysql会发现还是会报错:
image.png第二步
sudo mkdir -p /usr/local/opt/mysql-connector-c/lib
cd /usr/local/opt/mysql-connector-c/lib
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib libmysqlclient.18.dylib
ps: 这一步还不完全,导入_mysql会出现新的报错:
提示Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
image.png
第三步
cd /usr/local/opt/openssl/lib
sudo ln -s libssl.1.1.dylib libssl.1.0.0.dylib
继续导入_mysql 报错如下:Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
第四步
cd /usr/local/opt/openssl/lib
sudo ln -s libcrypto.1.1.dylib libcrypto.1.0.0.dylib
此时 导入_mysql就不会再报错了
总结:
sudo mkdir -p /usr/local/opt/mysql-connector-c/lib
sudo ln -s /usr/local/mysql/lib/libmysqlclient.20.dylib /usr/local/opt/mysql-connector-c/lib/libmysqlclient.18.dylib
sudo ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
sudo ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
网友评论