词条信息

admin
超级管理员
版本创建者 发短消息   
简易百科旧版 >> cygwin安装Mysql >> 历史版本

最新历史版本 :cygwin安装Mysql 返回词条



这段时间无意间碰到了cygwin,可以在window使用linux环境的,所以视图将一些使用过的东西安装到cygwin中,不过安装Mysql时遇到了不少问题,差点都放弃了。还好最后还是安装好了。以下是查到的教程帖。安装Mysql一般都需要对源码包进行编译,然后才安装。主要先把tar包下载下来后,然后编译安装就行了。

//////////////////////////////////////////////////////////////

在cygwin下编译MySQLdb for python(转)


目录

1. 准备回目录


由于cygwin自己不提供MySQLClient程序,所以要从源代码进行编译。

首先需安装cygwin,安装的时候要选择Devel、Perl、Python包。

下载对应的MySQL版本,注意要下载“Source”版本。

下载MySQLdb,以备安装。



2. 编译安装MySQLClient回目录


进入cygwin的Shell,解压MySQL代码:

tar -xvzf mysql-5.0.37.tar.gz

cd mysql-5.0.37


配置、编译、安装


./configure --without-server

make && make install


根据机器的配置,编译可能会花较长的时间,一般在半个小时左右。


3. 编译安装MySQLdb回目录


3.1. 解压

进入cygwin的Shell,解压MySQLdb:

tar -xvzf MySQL-python-1.2.2.tar.gz

cd MySQL-python-1.2.2


3.2. 编译前的设置

首先修改MySQLdb的编译配置文件:site.cfg,在MySQL-python-1.2.2目录下。

找到[options]项进行如下修改:

放开mysql_config = /usr/local/bin/mysql_config一行,屏蔽#registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0一行,因为cygwin属于类Linux不是Windows。

由于我们用在PC机上所以设置embedded为False。

设置threadsafe为False;我们尽量采用静态编译,static设为True。

最后的[options]如下:


[options]

# embedded: link against the embedded server library

# threadsafe: use the threadsafe client
# static: link against a static library (probably required for embedded)

embedded = False

threadsafe = False

static = True

# 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

# The Windows registry key for MySQL.

# This has to be set for Windows builds to work.

# Only change this if you have a different version.

#registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0


3.3. 编译、安装

cd MySQL-python-1.2.2

python setup.py build

python setup.py install

在安装过程中可能会要求下载setuptools,按要求下载即可。


另外安装完毕后为.egg文件,也可以使用lib.cygwin-1.5.24-i686-2.5下的文件,即直接将文件拷贝到python的site-packages就能使用。