当前位置:Gxlcms > 数据库问题 > python MySQLdb

python MySQLdb

时间:2021-07-01 10:21:17 帮助过:22人阅读

这个MySQLdb就是python操作MySQL数据库的模块

所以,你得先安装它,默认是没安装

 

一. 安装libmysqlclient-dev

#apt-get update

#apt-get install libmysqlclient-dev

二.安装setuptools

https://pypi.python.org/pypi/setuptools/

setuptools-36.7.0.zip

#unzip setuptools-36.7.0.zip

#cd setuptools-36.7.0

#python setup.py build

#python setup.py install

三.安装MySQL-python

https://pypi.python.org/pypi/MySQL-python/1.2.5

MySQL-python-1.2.5.zip

#cd MySQL-python-1.2.5

#vim setup_posix.py

修改mysql_config.path = “mysql_config"

为mysql_config.path = "/usr/bin/mysql_config"

#python setup.py build

#python setup.py install

四.验证

# python

Python 2.7.14 (default, Nov  1 2017, 00:48:15)

[GCC 4.8.4] on linux2

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

>>> import MySQLdb

/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc, but /home/woodzcl/MySQL-python-1.2.5 is being added to sys.path

OK,已经正确安装python的MySql模块

python MySQLdb

标签:ref   set   use   数据   pac   license   more   setup.py   site   

人气教程排行