Installing Mysql-python

Source: Internet
Author: User

1. Install with Yum

1.1 Check Mysql-python

[[email protected] mysql_tools]# python

Python 2.4.3 (#1, Dec 10 2010, 17:24:32)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import MySQLdb

Traceback (most recent):

File "<stdin>", line 1, in?

Importerror:no module named MySQLdb

>>>

1.2 Installing with Yum

[Email protected] mysql_tools]# yum-y install Mysql-python

Loaded Plugins:rhnplugin, security

This system isn't registered with the portal.

Portal support would be disabled.

Setting up Install Process

Resolving Dependencies

--Running Transaction check

......

Install 3 Package (s)

Upgrade 0 Package (s)


Total Download size:5.5 M

Downloading Packages:

(1/3): mysql-python-1.2.3-0.1.c1.el5.i386.rpm                     &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                    |  93 KB     00:00     

(2/3): perl-dbi-1.52-2.el5.i386.rpm                                                  ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                            | KB     00:01     

(3/3): mysql-5.0.95-5.el5_9.i386.rpm | 4.9 MB 00:12

......

complete!

[[email protected] mysql_tools]# python

Python 2.4.3 (#1, Dec 10 2010, 17:24:32)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import MySQLdb

>>>

OK, Mysql-python installation is complete.

2. Download and install

2.1 Downloads

[Email protected] shell]# wget http://sourceforge.net/projects/mysql-python/files/latest/download

[Email protected] shell]# TAR-ZXVF mysql-python-1.2.4b4.tar.gz

[Email protected] shell]# CD MYSQL-PYTHON-1.2.4B4

[email protected] mysql-python-1.2.4b4]# LL

Total 200

-rw-r--r--1 6296 Games 16295 Oct 9-distribute_setup.py

Drwxr-xr-x 2 6296 games 4096 Dec 01:29 doc

-rw-r--r--1 6296 Games 18092 Oct 9-GPL-2.0

-rw-r--r--1 6296 Games 5331 Oct 9

-rw-r--r--1 6296 Games 6636 Oct 9 INSTALL

-rw-r--r--1 6296 Games 317 Oct 9-manifest.in

-rw-r--r--1 6296 Games 2064 Oct 9-metadata.cfg

-rw-r--r--1 6296 Games 80837 Oct 9-_mysql.c

Drwxr-xr-x 3 6296 Games 4096 Dec 01:29 MySQLdb

-rw-r--r--1 6296 Games 2352 Oct 9-_mysql_exceptions.py

Drwxr-xr-x 2 6296 Games 4096 Dec 01:29 Mysql_python.egg-info

-rw-r--r--1 6296 Games 1726 Oct 9-Pkg-info

-rw-r--r--1 6296 Games 3203 Oct 9-pymemcompat.h

-rw-r--r--1 6296 Games 1266 Oct 4-readme.md

-rw-r--r--1 6296 Games 410 Oct 9-setup.cfg

-rw-r--r--1 6296 Games 1088 Oct 9-setup_common.py

-rw-r--r--1 6296 Games 3233 Oct 9-setup_posix.py

-rw-r--r--1 6296 Games 593 Oct 9-setup.py

-rw-r--r--1 6296 Games 1334 Oct 9-setup_windows.py

-rw-r--r--1 6296 Games 665 Oct 9-site.cfg

Drwxr-xr-x 2 6296 Games 4096 OCT 9-tests

2.1 Find the Mysql_config file location

[Email protected] mysql-python-1.2.4b4]# Find/-name Mysql_config

/usr/local/mysql/bin/mysql_config

2.2. Edit the Site.cfg file

[Email protected] mysql-python-1.2.4b4]# VI site.cfg

......

Embedded = False

#threadsafe = True

Threadsafe = False

static = False


# The path to Mysql_config.

# only use this if mysql_config are not on your PATH, or you have some weird

# setup that requires it.

#mysql_config =/usr/local/bin/mysql_config

Mysql_config =/usr/local/mysql/bin/mysql_config

# HTTP://STACKOVERFLOW.COM/QUESTIONS/1972259/MYSQL-PYTHON-INSTALL-PROBLEM-USING-VIRTUALENV-WINDOWS-PIP

# Windows Connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.

Connector = C:\Program Files (x86) \mysql\mysql connector C 6.0.2

2.3 Installation

[[email protected] mysql-python-1.2.4b4]# python setup.py build

[[email protected] mysql-python-1.2.4b4]# python setup.py install

3. Testing

[[email protected] mysql_tools]# python

Python 2.4.3 (#1, Dec 10 2010, 17:24:32)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import MySQLdb

>>>


Installing Mysql-python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.