---
title: "一键搞定python连接mysql驱动问题(windows版本)"
author: "qepwqnp"
date: "2011-06-21T17:49:14Z"
tags: []
categories: ["编程语言"]
slug: "python-mysql-windows"
draft: false
lastmod: "2012-07-23T09:20:18Z"
id: 1100147
url: "https://chengjunflying.iteye.com/blog/1100147"
---

对于mysql驱动问题折腾了一下午，现共享出解决方案
1：手动安装驱动
  完全是场噩梦,推荐大家采用自动安装
2：自动安装
   下载自动安装包，下载地址：http://www.codegood.com/archives/129
双击安装！安装完成后。已能正常对数据库操作
eg:

```java

import MySQLdb
con=MySQLdb.connect(host='localhost',user='root',passwd='root',db='test')
cursor = con.cursor()
sql = "select * from test"
cursor.execute(sql)
alldata = cursor.fetchall()
if alldata:
    for rec in alldata:
        print rec[0]
cursor.close()
con.close()

```
 
如果有朋友在eclispe中采用pydev时，import MySQLdb会出错，是因为eclipse不能自动识别驱动，采用办法，请google查询,可参见:http://www.3ppt.com/Design/Python/29551.html

提供windows上驱动两个，具体其它版本上官网下载