Install Connector/Python:
# Wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.11.zip
# Unzip mysql-connector-python-1.0.11.zip
# Cd mysql-connector-python-1.0.11
# Python setup. py install
Test whether Connector/Python is installed:
>>> From distutils. sysconfig import get_python_lib
>>> Print get_python_lib ()
/Usr/local/lib/python2.7/site-packages
Small instance:
[Root @ obe11g ~] # Python
Python 2.7.3 (default, Jul 18 2013, 20:53:58)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Import mysql. connector
>>> Cnx = mysql. connector. connect (user = 'waterbin', password = '000000', host = '192. 168.1.115', database = 'test ')
>>> Cur = cnx. cursor ()
>>> Cur.exe cute ('select * from t ')
>>> Print cur. fetchall ()
[(1,)]
>>> Cnx. close ()
For details about MySQL Connector/Python, click here
MySQL Connector/Python: click here