win7编译安装mysql

软件准备

   mysql   http://www.mysql.com/downloads/mysql/  mysql-5.5.21.zip 27.6MB mysql-5.1.61.zip 两个版本

 cmake http://www.cmake.org/files/v2.8/cmake-2.8.6-win32-x86.exe

 bison  http://en.sourceforge.jp/projects/sfnet_gnuwin32/downloads/bison/2.4.1/bison-2.4.1-setup.exe/

  vs2008  http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=d95598d7-aa6e-4f24-82e3-81570c5384cb#top
           注:本试用版具有零售版的全部功能,但将在 90 天后过期。
           园子里朋友介绍过的升级方法:把Setupsetup.sdb文件中的[Product Key],由T2CRQGDKBVW7KJR8C6CKXMW3D修改为PYHYPWXB3BB2CCMV9DX9VDY8T。因为九十天试用版本已经是Rtm版本,所以改变序列号以后的升级或者安装,就会变成正式版,不再有使用期限了。

 

安装vs2008,Cmake2.8,bison-2.4.1
 安装路径尽量不使用空格。C:\Cmake C:\bison,将 C:\CMake\bin;C:\bison\GnuWin32\bin;添加到环境变量

 CMD输入cmake 命令可执行

安装vs2008遇到错误 vs2008 安装失败 microsoft visual studio web 创作组件 安装失败 卸载了office2007再试ok。

解压mysql

编译mysql

 

cd mysql-5.5.21;
cmake . -G "Visual Studio 9 2008"  之后报错。非注册版VS2008? 

修改setup.sdb的序列号重装vs2008

cmake . -G "Visual Studio 9 2008"  之后如下图所示:

 

打开MySQL.sln;解决方案‘MySQL’99个项目。

打开mysql-5.1.61

运行win/configure.js脚本 cscript win/configure.js WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro 

运行结果:
done!

运行win/build-vs9.bat 批处理内调用的是CMake 在MySQL根目录生成了MySQL.sln


MySQL.sln;解决方案‘MySQL’56个项目。

找到mysql右键点生成,漫长的编译后,在G:\mysql-5.1.61\mysql-5.1.61\client\Debug生成了可执行文件mysql.exe

找到mysqld右键点生成,漫长的编译后报错,失败了,修改打开 sql\sql_locale.cc,并另存为Utf8格式,编译成功生成mysqld.exe,可是执行却报错。

说mysqld.cc 4198行有错 定位DBUG_ASSERT(0); 这句代码加入了一个断言,该断言始终为False,抛出了异常,改为DBUG_ASSERT(1);成功生成,cmd进入G:\mysql-5.1.61\mysql-5.1.61\sql\Debug 执行mysqld正常提供服务。再进入client\Debug,运行 mysql -uroot -p 密码为空,可以访问mysql数据库了。

回到VS,编译mysqladmin成功。mysqladmin shutdown -u root -p关闭数据库服务。

回到5.5的方案,编译mysql就不顺利了,出错,什么也没变动,重新生成,又成功了。client\Debug里有了exe文件。

编译mysqld,innobase里n多的警告。sql_locale.cc里又一堆错误。

打开 mysql-5.5.21\sql\sql_locale.cc,并另存为Utf8格式 没用。这是一个本地化的咚咚,只留下english其他的全砍掉试试,通过了!

有人说
修改 mysql-5.5.21\sql\sql_locale.cc下的my_locales结构体下的除了第一个&my_locale_en_US,和最后一NULL之外其他的值全部注释掉
我试了一下不行 再试 可以通过

运行mysqld 报错

share目录和my.ini的问题 进入windows目录修改my.ini

[mysqld]
# set basedir to your installation path
#basedir=G:/mysql-5.1.61/mysql-5.1.61
basedir=G:/mysql-5.5.21/mysql-5.5.21
# set datadir to the location of your data directory
#datadir=G:/mysql-5.1.61/mysql-5.1.61/win/data
datadir=G:/mysql-5.5.21/mysql-5.5.21/win/data

在win下建立data目录,再把sql下的share内目录copy到mysql-5.5.21目录下

执行mysqld。打开data目录,发现有个错误日志。第一行是

mysqld: Table 'mysql.plugin' doesn't exist
120224 17:33:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

只生成了服务和客户端,没生成整个方案。生成方案又失败报错。

一些网贴

http://www.cnblogs.com/nocode/archive/2011/04/10/2011844.html

http://www.cnblogs.com/yuemenglong/archive/2011/06/14/2080262.html

http://blog.csdn.net/yuyunliuhen/article/details/6143347

http://www.51testing.com/?uid-66291-action-viewspace-itemid-805844

http://bygreencn.wordpress.com/2011/08/19/vs2010%E7%BC%96%E8%AF%91mysql-5-5-15%E5%B9%B6%E7%94%9F%E6%88%90%E5%AE%89%E8%A3%85%E5%8C%85/

1.准备:
a. 下载mysql-5.5.15.zip http://dev.mysql.com/downloads/mysql/
b. 下载较新版本的CMake并安装,我使用的是CMake 2.85
c. 下载bison并安装,注意安装目录不能有空格.http://gnuwin32.sourceforge.net/packages/bison.htm
2. 解压mysql-5.5.15.zip,修改sql\sql_locale.cc,因该文件中有很多vs2010不能识别的多国语言的字符编码,实验发现及时改变成任何utf8类型的编码格式仍不行,后发现vs2010有对UTF8兼容的bug,故只好修改该文件,让它暂时只支持en_US一种语言。
3.将bison安装目录中bin\m4.exe拷贝到mysql-5.5.15\sql目录,使其与sql_yacc.cc在同一个目录下,此问题为bison调用m4.exe时无法找到其路径,应该是cmakelist.txt的问题。期间可能还会发生m4.exe找不到GNUWin32包的动态库的问题,去GNUWin32找相应的库下载并拷贝到mysql-5.5.15\sql下。
4.cmake gui 下配置生成工程文件MySQL.sln.
5.控制台下进到MySQL.sln所在目录执行:

"c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" MySQL.sln /build RelWithDebInfo
"c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" MySQL.sln /build RelWithDebInfo /project initial_database
"c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" MySQL.sln /build RelWithDebInfo /project PACKAGE
"c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" MySQL.sln /clean
至此如果没有异议会在MySQL.sln所在目录会找到_CPack_Packages\win32\ZIP,会有一个mysql-5.5.15-win32.zip和完整的安装包mysql-5.5.15-win32,这就是最终生成的可以使用的安装包了。

********************************************************************

updated for mysql-5.5.16:

同样是m4.exe生成sql_yacc.cc的问题,在此版本中,需要copy m4.exe及其依赖的动态库与MySQL.sln保持在同一个目录下。–2011-09-22

 

In the “Solution Explorer” view (far right-hand side of page), right-click on “PACKAGE” -> then “Build”.

If you have problems with this, it can be pieced together easily enough:

Make main dir mysql-5.5.xx
Make subdir bin/ - copy in all .exe files (from client/debug, sql/debug, */debug, etc.)*
Make subdir data/ - copy from sql/data/
Make subdir scripts/ – copy from scripts/ (at least all perl, sql, and sh scripts)
Make subdir share/ - copy from sql/share/
Create my.ini
* Notes re: .exe files: mysqld.exe is located in /sql/debug/ and mysql.exe is located in /client/debug/. The remaining .exe files are located in /client/debug/, /sql/debug/, /extra/debug/, /libmysql/debug/, /mysys/debug/, /scripts/debug/, /storage/myisam/debug/, /storage/heap/debug/, and /tests/debug/.


mysqld: Table 'mysql.plugin' doesn't exist

开始还以为是编译出了问题
把G:\mysql-5521\mysql-5.5.21\sql\data\mysql copy 到G:\mysql-5521\mysql-5.5.21\win\data 下问题解决。


cscript win/configure.js WITH_LILLIAN_STORAGE_ENGINE WITH_MYISAM_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro 

cmake . -G "Visual Studio 9 2008" 

或 win/build-vs9.bat 

posted on 2012-02-23 11:47  bigshuai  阅读(1122)  评论(0编辑  收藏  举报