码迷,mamicode.com
首页 > 数据库 > 详细

python MySQLdb

时间:2017-11-10 20:37:18      阅读:256      评论:0      收藏:0      [点我收藏+]

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

这个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   

原文地址:http://www.cnblogs.com/woodzcl/p/7815970.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!