歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux非root用戶安裝Python+MySQLdb

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  如果不出現異常則安裝成功

Copyright © Linux教程網 All Rights Reserved