Linux非root用户安装Python+MySQLdb

zhangm 2012-07-27

Linux非root用户安装Python+MySQLdb,最近实习要求非root用户安装各种环境,特此记下日记。

1.安装python

wget python和mysqldb的源码包

Python : http://www.python.org/getit/

MySQLdb: http://sourceforge.net/projects/mysql-python/

tar -zxvf Python-2.7.3.tgz

cd Python-2.7.3

./configure --prefix=your_python_dir(你准备安装的路径)

make && make install

2.安装setuptools

tar -zxvf setuptools-0.6c11.tar.gz

cd setuptools-0.6c11

# your_python_dir/bin/python2.7 setup.py build

# your_python_dir/bin/python2.7 setup.py install

3.安装MySQLdb

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

cd MySQL-python-1.2.3

vim site.cfg 修改mysql路径

去掉mysql_config前边的‘#’修改mysql_config的路径

(例:mysql_config = /home/$USER/local/mysql/bin/mysql_config)

# your_python_dir/bin/python2.7 setup.py build

# your_python_dir/bin/python2.7 setup.py install

4.测试是否安装成功

# your_python_dir/bin/python2.7

import MySQLdb  如果不出现异常则安装成功

相关推荐