您的位置:首页 > 数据库 > MySQL

MySQLdb安装

2015-09-25 11:04 591 查看
1、下载MySQLdb安装包:

wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz?use_mirror=nchc
2、解压

tar -zxvf MySQL-python-1.2.3c1.tar.gz

3、更改配置

cd MySQL-python-1.2.3c1

whereis mysql_config 获取位置,一般位于/usr/bin/mysql_config

vim site.cfg

更改:mysql_config = /usr/bin/mysql_config

更改:threadsafe = True

4、测试

Python

import MySQLdb

有可能报:site-packages/pkg_resources.py:1031: UserWarning: /home/***/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment
variable).

修改方式给.python-eggs加权限:chmod g-wx,o-wx .python-eggs/

然后继续测试:import MySQLdb

如果无报错则安装成功
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: