How to install MySQLdb in Python 2.6 CentOS

与世无争的帅哥 提交于 2019-12-01 17:37:58

You can install it via yum, it is case sensitive:

[root@localhost ~]# yum install MySQL-python
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nfsi.pt
 * extras: mirrors.nfsi.pt
 * updates: mirrors.nfsi.pt
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package MySQL-python.x86_64 0:1.2.3-0.3.c1.1.el6 will be installed
--> Finished Dependency Resolution
...

It works with the following repositories (CentOS 6):

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nfsi.pt
 * extras: mirrors.nfsi.pt
 * updates: mirrors.nfsi.pt
repo id      repo name            status
base         CentOS-6 - Base      6.381
extras       CentOS-6 - Extras    12
updates      CentOS-6 - Updates   458
repolist: 6.851

MySQL-python exists in PyPi. Try doing either of the following :

pip install MySQL-python

or

easy_install MySQL-python
kagat-kagat

Thanks guys for all the help but none of them works for me. I found this interesting article on web on how to set up the package for Python 2.6 CentOS 5.5, this works for me.

First, I install some stuffs used to build RPMs

yum -y install rpm-build gcc-c++

And some dependencies

yum -y install readline-devel openssl-devel gmp-devel ncurses-devel
yum -y install gdbm-devel expat-devel libGL-devel libX11-devel tcl-devel tk-devel
yum -y install tix-devel sqlite-devel db4-devel

Grabbed src RPM

rpm -Uvh http://mirrors.geekymedia.com/centos/python26-2.6-geekymedia1.src.rpm

And lastly

yum install -y mysql-devel
curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv
cd MySQL-python-1.2.3
python setup.py build
python setup.py install

You might want to add the EPEL Repo:

/bin/rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm creates=/etc/yum.repos.d/epel.repo

then enable it in /etc/yum.repos.d/epel.repo: set enabled=1

try yum install gcc-c++ MySQL-python afterwards.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!