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 ~] # Pythonpython 2.7.3 (default, Jul 18 2013, 20:53:58) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3.1)] on linux2type "help", "Copyright ", "Credits" or "License" for more information. >>> import MySQL. connector >>> CNX = MySQL. connector. connect (user = 'waterbin', password = '000000', host = '000000. 168.1.115', database = 'test') >>> cur = CNX. cursor () >>> cur.exe cute ('select * from t') >>> print cur. fetchall () [(1,)]
>>> CNX. Close ()
By dba_waterbin
2013-07-25
Good luck