Python2.7.3 + mysqldb

Source: Internet
Author: User

1. Install python2.7.3
[Root @ centos ~] # Wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
[Root @ centos ~] # Tar jxvf Python-2.7.3.tar.bz2
[Root @ centos ~] # Cd Python-2.7.3
[Root @ centos ~] # Make & make install
[Root @ centos ~] # Rm/usr/bin/Python & ln-S/usr/local/Python/bin/Python/usr/bin/Python
[Root @ centos ~] # Python-V

2 install setuptools-0.6c11
[Root @ centos ~] # Wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
[Root @ centos ~] # Tar zxvf setuptools-0.6c11.tar.gz
[Root @ centos ~] # Cd setuptools-0.6c11
[Root @ centos ~] # Python setup. py build
[Root @ centos ~] # Python setup. py install

3. Install mysql-Python
[Root @ centos ~] # Http://pypi.python.org/pypi/MySQL-python/#downloads
[Root @ centos ~] # Tar zxvf MySQL-python-1.2.3.tar.gz
[Root @ centos ~] # Cd MySQL-python-1.2.3
[Root @ centos ~] # Python setup. py build
[Root @ centos ~] # Python setup. py install

5. Test
[root @ centos ~] # Python
Python 2.7.3 (default, Nov 30 2012, 11:55:02)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
type "help", "Copyright", "Credits" or "License" for more information.
Import mysqldb
db_conn = mysqldb. connect (host = '2017. 0.0.1 ', user = 'root', passwd = '000000', DB = 'test')
db_curs = db_conn.cursor ()
db_curs.execute ("show databases;")
4l
for data in db_curs.fetchall ():
... print data
...
('information _ scheme',)
('masterslave ',)
('mysql',)
('test ',)

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.