1.python是ubuntu自带的,版本号2.7
2.mysql安装
(1)从官网上下载linux下的mysql安装包mysql-5.6.14-linux-glibc2.5-i686.tar.gz
(2)拷贝到/usr/local,tar -xvf mysql***.tar.gz
(3)添加mysql用户组, sudo gourpadd mysql,mkdir /home/mysql,为mysql账户建立文件夹
(4)添加mysql账户,sudo useradd -g mysql -d /home/mysql mysql
(5)建立解压目录的链接,简化名称 ln -s mysql***** mysql
(6)cd /usr/local/mysql, chown -R mysql . ,chgrp -R mysql ., 修改mysql文件夹的所属用户组和账户
(7)执行安装 ./scripts/mysql_install_db --user=mysql。 mysql -u root password '***'修改密码
(8)cp supprt-file/mysql.server /etc/init.d/mysql
问题:mysql start报错
修改报错文件路径的账户权限,具体忘记了
3.mysqldb安装
(1)下载安装包,解压缩
(2)执行sudo python setup.py build
问题:报错Infileincludedfrom_mysql.c:29:
pymemcompat.h:10:20:
error: Python.h: No suchfileordirectory
_mysql.c:30:26:
error: structmember.h: No suchfileordirectory
Infileincludedfrom/usr/include/mysql/mysql.h:44,from_mysql.c:40:
. . . _mysql.c:2808:
warning:returntypedefaults
to'int'_mysql.c:
In function'DL_EXPORT':
_mysql.c:2808:
error: expected declaration specifiers before'init_mysql'_mysql.c:2886:
error: expected'{'at
end ofinputerror:
command'gcc'failedwithexit
status
执行sudo apt-get install python-dev
(3)sudo python setup.py install
问题:mysql_config: not found
首先查找mysql_config的位置,使用find / -name mysql_config ,比如我的在/usr/local/mysql/bin/mysql_config
修改setup_posix.py文件,在26行:mysql_config.path = "mysql_config" 修改为:mysql_config.path = "/usr/local/mysql/bin/mysql_config"修改完成后保存,再执行python setup.py buildpython setup.py installpython setup.py bdist_rpm
4.安装完成后,import MySQLdb报错
问题:File “MySQLdb/__init__.py”, line 19, in
import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
ln-s/usr/local/mysql/lib/libmysqlclient.so.18
/usr/lib/libmysqlclient.so.18
全部完成