我在http://www.mysql.com/downloads/connector/c/找到了mysqllib。
那么我可以在不安装MySQL服务器的情况下安装MySQLdb吗?
只需将mysqlib复制到/usr/local/mysql
?
有可能吗?怎么做?
哪个版本与我的机器匹配(我使用OSX Lion)?
我想用它连接到Django的另一台机器上的MySQL服务器。
感谢您的帮助!
================================
我已经尝试过了
提取到/ usr / local / mysql
下载MySQL-python-1.2.3
创建符号链接gcc-4.2到gcc(因为在编译时运行gcc-4.2而不是gcc)
在MySQL-python-1.2.3文件夹中编辑setup_posix.py 编辑mysql_config.path =“/ usr / local / mysql / bin / mysql_config”
sudo python setup.py clean
编辑_mysql.c每个包含mysqllib到正确的路径
示例#include“mysql.h”===> #include“/usr/local/mysql/include/mysql.h”
我发现了这个错误
Oats-MacBook:MySQL-python-1.2.3 Oat$ sudo python setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.6-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.6-intel-2.7
creating build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
creating build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-intel-2.7
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:185:1: warning: "SIZEOF_LONG" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:9,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:54:1: warning: this is the location of the previous definition
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:205:1: warning: "SIZEOF_SIZE_T" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:9,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:56:1: warning: this is the location of the previous definition
gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.6-intel-2.7/_mysql.o -L/usr/local/lib -lmysql -lpthread -o build/lib.macosx-10.6-intel-2.7/_mysql.so
ld: warning: directory not found for option '-L/usr/local/lib'
ld: library not found for -lmysql
collect2: ld returned 1 exit status
ld: warning: directory not found for option '-L/usr/local/lib'
ld: library not found for -lmysql
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccnEbgua.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
答案 0 :(得分:2)
您可能需要尝试PyMySQL - 它是MySql客户端的python实现。因此,您无需使用二进制文件和管理员权限。
答案 1 :(得分:0)
您想在另一台机器上连接到MySQL服务器吗?如果是这样,那么最简单的方法就是安装你的(我推测)Linux发行版附带的libmysql包。
如果您正在谈论MySQL的嵌入式版本(没有任何服务器),那么您需要下载mysql-python的源代码,修改site.cfg以指定对嵌入式而非服务器的支持并重建它。 / p>