MySQL 配置不当的原因:不安全的使用相对路径
我正在使用 Django,当我运行 python manage.py runserver
时,我收到以下错误:
I'm using Django, and when I run python manage.py runserver
I receive the following error:
ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/_mysql.so
Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Python/2.7/site-packages/_mysql.so with restricted binary
我不完全确定如何解决这个问题.我已经通过 pip 安装了 MySQL-python.我更早地遵循了此步骤.
I'm not entirely sure how to fix this. I have installed MySQL-python via pip. And I followed this step earlier.
我还想指出这是 El Capitan Beta 3.
I want to also point out this is with El Capitan Beta 3.
推荐答案
在 OS X El Capitan (10.11) 中,Apple 添加了 系统完整性保护.
In OS X El Capitan (10.11), Apple added System Integrity Protection.
这可以防止/usr
等受保护位置中的程序调用使用对另一个共享库的相对引用的共享库.对于_mysql.so
,它包含对共享库libmysqlclient.18.dylib
的相对引用.
This prevents programs in protected locations like /usr
from calling a shared library that uses a relative reference to another shared library. In the case of _mysql.so
, it contains a relative reference to the shared library libmysqlclient.18.dylib
.
未来可能会更新共享库_mysql.so
.在此之前,您可以通过 install_name_tool
实用程序强制它使用绝对引用.
In the future, the shared library _mysql.so
may be updated. Until then, you can force it to use an absolute reference via the install_name_tool
utility.
假设libmysqlclient.18.dylib
在/usr/local/mysql/lib/,然后运行命令:
Assuming that libmysqlclient.18.dylib
is in /usr/local/mysql/lib/, then run the command:
sudo install_name_tool -change libmysqlclient.18.dylib \
/usr/local/mysql/lib/libmysqlclient.18.dylib \
/Library/Python/2.7/site-packages/_mysql.so
相关文章