安裝MySQL
去MySQL官網(wǎng)下載安裝包進(jìn)行安裝
安裝MySQLdb
- 下載源代碼安裝包雀彼,解壓;
- 終端cd到解壓目錄下常挚;
- 編譯纳猫,執(zhí)行下列代碼:
python setup.py build
- 安裝:
python setup.py install
若出錯绳匀,請注意一下問題粒竖。
問題
- 若出現(xiàn)
error: can't create or remove files in install directory
則執(zhí)行下列代碼:
sudo python setup.py install
- 如出現(xiàn)
mysql_config not found
照捡,則需要修改mysql_config的路徑叮贩;
- 在解壓的目錄下找到site.cfg文件击狮,并找出以下內(nèi)容:
# 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"