先装Python,由于Fedora 14系统已有python,将python安装至home目录下;
修改home目录下.bash_profile文件,添加python/bin路径到PATH中;
添加MySQLdb,遇到很多问题
linux 安装mysqldb:
1. 创建/usr/local/python
2.复制setuptools-0.6c11-py2.6.egg到/usr/local/python
3.执行sh setuptools-0.6c11-py2.6.egg
4.复制MySQL-python-1.2.3.tar.gz到当前目录
5.解压
6.修改site.cfg中的mysql_config,改成mysql安装目录下的mysql_config路径,如:/usr/local/mysql/mysql/bin/mysql_config
7.执行python setup.py build
8.执行python setup.py install
9.成功后,执行import MySQLdb,看成功否,一般来说,这时候不成功的错误如下:
mysqldb安装出错:
1.zipimport.ZipImportError: can’t decompress data; zlib not available
解决办法重新编译一下Python源码安装包,如下:
1 tar jxvf Python-2.5.2.tar.bz2 2 cd Python-2.5.2/
3 ls
4 sudo ./configure 5 gvim Modules/Setup
6 sudo gvim Modules/Setup
在这里把454行左右的 找到
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
去掉注释
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
然后重新编译,安装python
2.ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
#解决方法
#updatedb
#locate libmysqlclient_r.so.16
/usr/local/mysql-5.1.30-linux-i686-glibc23/lib/libmysqlclient_r.so.16.0.0
/usr/local/mysql-5.1.30-linux-i686-glibc23/lib/libmysqlclient_r.so.16
/usr/local/mysql/lib/mysql/libmysqlclient_r.so.16
/usr/local/mysql/lib/mysql/libmysqlclient_r.so.16.0.0
#vi /etc/ld.so.conf
在ld.so.conf中加入:
/usr/local/mysql/lib/mysql/
#ldconfig -v
再次测试,成功!