MySQL-python安装
时间:2010-02-24 来源:yaoshiyan
下载python2.4
wget http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tgz
tar -xzvf Python-2.4.4.tgz
cd Python-2.4.4
./configure
make
make insall
下载MySQL-python-1.2.2.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
tar -xzvf MySQL-python-1.2.2.tar.gz
cd MySQL-python-1.2.2
vi site.cfg
配置mysql_config的路径
然后运行
python setup.py install或
python setup.py build
(中途会自动下载http://cheeseshop.python.org/packages/2.4/s/setuptools/setuptools-0.6c5-py2.4.egg,如果无法下载,请自行下载到当前目录。)
提示出现
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
此提示意为mysqclient_r需要你在编译mysql时带上--enable-thread-safe 参数
重新编译mysql
./configure --prefix=/usr/local/mysql --enable-thread-safe --enable-assembler --enable-shared --with-charset=utf8 -with-mysqld-ldflags=-all-static --without-debug
再次运行
python setup.py build
还是不对。
vi site.cfg
把threadsafe = True改为false
运行python mysql_test.py出现错误
libmysqlclient.so.15没有
去python安装目录下
ldd ./build/lib.linux-i686-2.4/_mysql.so
发现libmysqlclient.so.15 没有找到
cp /usr/local/mysql/lib/mysql/libmysqlclient.so.15 /usr/lib/
OK
python脚本可以执行mysql语句了。
wget http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tgz
tar -xzvf Python-2.4.4.tgz
cd Python-2.4.4
./configure
make
make insall
下载MySQL-python-1.2.2.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
tar -xzvf MySQL-python-1.2.2.tar.gz
cd MySQL-python-1.2.2
vi site.cfg
配置mysql_config的路径
然后运行
python setup.py install或
python setup.py build
(中途会自动下载http://cheeseshop.python.org/packages/2.4/s/setuptools/setuptools-0.6c5-py2.4.egg,如果无法下载,请自行下载到当前目录。)
提示出现
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
此提示意为mysqclient_r需要你在编译mysql时带上--enable-thread-safe 参数
重新编译mysql
./configure --prefix=/usr/local/mysql --enable-thread-safe --enable-assembler --enable-shared --with-charset=utf8 -with-mysqld-ldflags=-all-static --without-debug
再次运行
python setup.py build
还是不对。
vi site.cfg
把threadsafe = True改为false
运行python mysql_test.py出现错误
libmysqlclient.so.15没有
去python安装目录下
ldd ./build/lib.linux-i686-2.4/_mysql.so
发现libmysqlclient.so.15 没有找到
cp /usr/local/mysql/lib/mysql/libmysqlclient.so.15 /usr/lib/
OK
python脚本可以执行mysql语句了。
相关阅读 更多 +