Mysqldb-python Installation

Source: Internet
Author: User

The installation is simple and the steps are as follows:

Early: yum-y install Python-setuptools, or your own online source package installation

1. Download the installation package:

#wget Https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip--no-check-certificate

#unzip Mysql-python-1.2.5.zip

#cd mysql-python-1.2.5

#python setup.py Build

[[email protected] mysql-python-1.2.5]# python setup.py buildrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-2.6copying _mysql_exceptions.py-build/lib.linux-x86_64-2.6Creating build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/__init__.py-build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/converters.py-build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/connections.py-build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/cursors.py-build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/release.py-build/lib.linux-x86_64-2.6/mysqldbcopying mysqldb/times.py-build/lib.linux-x86_64-2.6/mysqldbcreating build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/__init__.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/cr.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/field_type.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/er.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/flag.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/refresh.py-build/lib.linux-x86_64-2.6/mysqldb/constantscopying mysqldb/constants/client.py-build/lib.linux-x86_64-2.6/mysqldb/constantsrunning build_extbuilding ' _mysql ' extensioncreating build/temp.linux-x86_64-2.6gcc-pthread-fno-strict-aliasing-o2-g-pipe-wall-wp,-d_fortify_source=2-fexceptions-fstack-protector--param=ssp-buffer-size=4-m64-mtune=generic-d_gnu_source-fpic -fwrapv-dndebug-o2-g-pipe-wall-wp,-d_fortify_source=2-fexceptions-fstack-protector--param=ssp-buffer-size=4- m64-mtune=generic-d_gnu_source-fpic-fwrapv-fpic-dversion_info= (1,2,5, ' final ', 1)-d__version__=1.2.5-i/usr/ Include/mysql-i/usr/include/python2.6-c _mysql.c-o build/temp.linux-x86_64-2.6/_mysql.o-g-pipe-wp,-d_fortify_ Source=2-fexceptions-fstack-protector--param=ssp-buffer-size=4-m64-d_gnu_source-d_file_offset_bits=64-d_largefile_source-fno-strict-aliasing-fwrapv-fpic-duniv_linux-duniv_linuxin file included from/usr/include/ Mysql/my_config.h:14,From _mysql.c:44:/usr/include/mysql/my_config_x86_64.h:1082:1: Warning: "Have_wcscoll"Redefinedin file included From/usr/include/python2.6/pyconfig.h:6,From/usr/include/python2.6/python.h:8,From _mysql.c:29:/usr/include/python2.6/pyconfig-64.h:808:1: Warning:this is the location of the previous definitiongcc-pthread-shared build/temp.linux-x86_64-2.6/_mysql.o-l/usr/lib64/mysql-l/usr/lib64-lmysqlclient_r-lz-lpthread-lcrypt-lnsl-lm-lpthread-lssl-lcrypto-lpy Thon2.6-o build/lib.linux-x86_64-2.6/_mysql.so
View Code

#python setup.py Install

[[email protected]]# python setup.py installrunning installrunning bdist_eggrunning egg_infowriting mysql_python.egg-info/ Pkg-infowriting top-level names to mysql_python.egg-info/top_level.txtwriting Dependency_links to MySQL_ Python.egg-info/dependency_links.txtreading manifest file ' mysql_python.egg-info/sources.txt ' reading manifest Template ' manifest.in ' writing MANIFEST file ' mysql_python.egg-info/sources.txt ' Installing library code to build/ Bdist.linux-x86_64/eggrunning install_librunning build_pycopying mysqldb/release.py build/lib.linux-x86_64- 2.6/mysqldbrunning build_extcreating build/bdist.linux-x86_64creating build/bdist.linux-x86_64/eggcreating build/ Bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/mysqldb/times.py, build/bdist.linux-x86_64/egg/mysqldbcreating build/bdist.linux-x86_64/egg/mysqldb/ Constantscopying build/lib.linux-x86_64-2.6/mysqldb/constants/__init__.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/ lib.linux-x86_64-2.6/mysqldb/constants/refresh.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/lib.linux-x86 _64-2.6/mysqldb/constants/cr.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/lib.linux-x86_64- 2.6/mysqldb/constants/client.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/lib.linux-x86_ 64-2.6/mysqldb/constants/flag.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/lib.linux-x86_64 -2.6/mysqldb/constants/er.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/lib.linux-x86_64- 2.6/mysqldb/constants/field_type.py, build/bdist.linux-x86_64/egg/mysqldb/constantscopying build/ lib.linux-x86_64-2.6/mysqldb/cursors.py, build/bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/mysqldb/converters.py, build/bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/mysqldb/__init__.py, build/bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/mysqldb/connections.py, build/bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/mysqldb/release.py, build/bdist.linux-x86_64/egg/mysqldbcopying build/lib.linux-x86_64-2.6/_mysql.so, build/bdist.linux-x86_64/eggcopying build/lib.linux-x86_64-2.6/_mysql_exceptions.py, Build/bdist.linux-x86_64/eggbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/ times.py to times.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/constants/__init__.py to __init__. Pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/constants/refresh.py to Refresh.pycbyte-compiling build/ bdist.linux-x86_64/egg/mysqldb/constants/cr.py to Cr.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/ constants/client.py to client.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/constants/flag.py to Flag.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/constants/er.py to Er.pycbyte-compiling build/ bdist.linux-x86_64/egg/mysqldb/constants/field_type.py to Field_type.pycbyte-compiling build/bdist.linux-x86_64/ egg/mysqldb/cursors.py to cursors.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/converters.py to Converters.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/__init__.py to __init__.pycbyte-compiling build/ Bdist.linux-x86_64/egg/mysqldb/connections.py to connections.pycbyte-compiling build/bdist.linux-x86_64/egg/mysqldb/release.py to Release.pycbyte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyccreating stub Loader for _mysql.sobyte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyccreating build/ Bdist.linux-x86_64/egg/egg-infocopying Mysql_python.egg-info/pkg-info-build/bdist.linux-x86_64/egg/ Egg-infocopying Mysql_python.egg-info/sources.txt, build/bdist.linux-x86_64/egg/egg-infocopying MySQL_ Python.egg-info/dependency_links.txt, Build/bdist.linux-x86_64/egg/egg-infocopying MySQL_python.egg-info/top _level.txt, Build/bdist.linux-x86_64/egg/egg-infowriting build/bdist.linux-x86_64/egg/egg-info/native_ Libs.txtzip_safe Flag Not set;Analyzing archive Contents ...creating distcreating ' dist/mysql_python-1.2.5-py2.6-linux-x86_64.egg ' and adding ' Build/bdist.linux-x86_64/egg ' to Itremoving ' Build/bdist.linux-x86_64/egg ' (and Everything under it) processing mysql_python-1.2.5-py2.6-linux-x86_64.eggcreating/usr/lib64/python2.6/site-packages/mysql_python-1.2.5-py2.6-linux-x86_64.eggextracting mysql_python-1.2.5-py2.6-linux-x86_64.egg to/usr/lib64/python2.6/site-packagesadding Mysql-python1.2.5To easy-install.pth Fileinstalled/usr/lib64/python2.6/site-packages/mysql_python-1.2.5-py2.6-linux-x86_64.eggprocessing dependencies for Mysql-python==1.2.5finished processing dependencies for Mysql-python==1.2.5
View Code

Test:

[[email protected] mysql-python-1.2.5]  2.6.6 (r266:84292, Jan, 09:42:36[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
    "Help", "copyright", "credits" or "license" for more information.>>> import mysqldb>> > Quit () did not successfully install the test will prompt:>>> import mysqldbtraceback (most recent call last)  :"<stdin>", line 1, In <module>importerror:no module named MySQLdb

Errors encountered during installation:

If you execute the python setup.py build times error Environmenterror:mysql_config not found, you need to do the following:

1. Find the location of the mysql_config using the Find/-name mysql_config, such as/usr/bin/mysql/mysql_config

2. Modify the Mysql-python-1.2.5/site.cfg file, remove the mysql_config=xxx comment, and change it to Mysql_config=/usr/bin/mysql/mysql_config

3. If there is no Mysql_config command, you will need to install the following package:

Yum-y Install Mysql-server mysql-devel mysql-shared

Mysqldb-python Installation

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.