安装MySQL
去MySQL官网下载安装包进行安装
安装MySQLdb
- 下载源代码安装包,解压;
- 终端cd到解压目录下;
- 编译,执行下列代码:
python setup.py build
- 安装:
python setup.py install
若出错,请注意一下问题。
问题
- 若出现
error: can't create or remove files in install directory
则执行下列代码:
sudo python setup.py install
- 如出现
mysql_config not found
,则需要修改mysql_config的路径;
- 在解压的目录下找到site.cfg文件,并找出以下内容:
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
# mysql_config = /usr/local/bin/mysql_config
将最后一句句首的“#”去掉,并修改为:
mysql_config = /usr/local/mysql/bin/mysql_config
- 找到setup_posix.py中的
mysql_config.path = "mysql_config"
改为
mysql_config.path = "/usr/local/mysql/bin/mysql_config"