How to build MySQL on Windows

To build on Windows takes time a lot.

Prior Condition

Build Envirionment

Windows XP Professional SP2 Debian GNU Linux 3.1(sarge) and other Linux environment

Visual Studio Version

Visual Studio 2005 Professional Edition

MySQL

Before MySQL 5.0. After version 5.1, Windows source and Linux source is likely common source.

Installing Steps

1. Download MySQL installer soruce

Download source code and installer from http://dev.mysql.com/downloads/mysql/5.0.html

2. Install MySQL

Start with installing MySQL by installer that is not for Windows. This steps need to create data directory and register services.

3. Make MySQL on Linux

Make MySQL with Senna on Linnux. In follows explain for the case of running make at ~/mysql-5.0.24a.senna. Please refer install to get the way of making.

4. Expand MySQL source for Windows at mysql-5.0.24a-win

Expand downloaded MySQL source code for Windows. In this case ~/mysql-5.0.24a-win is used.

5. Copy required files. Run commands below

 cp mysql-5.0.24a.senna/include/my_pthread.h mysql-5.0.24a-win/include/my_pthread.h
 cp mysql-5.0.24a.senna/include/myisam.h mysql-5.0.24a-win/include/myisam.h
 cp mysql-5.0.24a.senna/libmysqld/filesort.cc mysql-5.0.24a-win/libmysqld/filesort.cpp
 cp mysql-5.0.24a.senna/libmysqld/ha_myisam.cc mysql-5.0.24a-win/libmysqld/ha_myisam.cpp
 cp mysql-5.0.24a.senna/libmysqld/item_cmpfunc.cc mysql-5.0.24a-win/libmysqld/item_cmpfunc.cpp
 cp mysql-5.0.24a.senna/libmysqld/item_func.cc mysql-5.0.24a-win/libmysqld/item_func.cpp
 cp mysql-5.0.24a.senna/libmysqld/item_sum.cc mysql-5.0.24a-win/libmysqld/item_sum.cpp
 cp mysql-5.0.24a.senna/libmysqld/records.cc mysql-5.0.24a-win/libmysqld/records.cpp
 cp mysql-5.0.24a.senna/libmysqld/sql_db.cc mysql-5.0.24a-win/libmysqld/sql_db.cpp
 cp mysql-5.0.24a.senna/libmysqld/sql_delete.cc mysql-5.0.24a-win/libmysqld/sql_delete.cpp
 cp mysql-5.0.24a.senna/libmysqld/sql_select.cc mysql-5.0.24a-win/libmysqld/sql_select.cpp
 cp mysql-5.0.24a.senna/libmysqld/sql_show.cc mysql-5.0.24a-win/libmysqld/sql_show.cpp
 cp mysql-5.0.24a.senna/libmysqld/sql_table.cc mysql-5.0.24a-win/libmysqld/sql_table.cpp
 cp mysql-5.0.24a.senna/myisam/ft_boolean_search.c mysql-5.0.24a-win/myisam/ft_boolean_search.c
 cp mysql-5.0.24a.senna/myisam/ft_nlq_search.c mysql-5.0.24a-win/myisam/ft_nlq_search.c
 cp mysql-5.0.24a.senna/myisam/ft_update.c mysql-5.0.24a-win/myisam/ft_update.c
 cp mysql-5.0.24a.senna/myisam/fulltext.h mysql-5.0.24a-win/myisam/fulltext.h
 cp mysql-5.0.24a.senna/myisam/mi_check.c mysql-5.0.24a-win/myisam/mi_check.c
 cp mysql-5.0.24a.senna/myisam/mi_close.c mysql-5.0.24a-win/myisam/mi_close.c
 cp mysql-5.0.24a.senna/myisam/mi_create.c mysql-5.0.24a-win/myisam/mi_create.c
 cp mysql-5.0.24a.senna/myisam/mi_delete_all.c mysql-5.0.24a-win/myisam/mi_delete_all.c
 cp mysql-5.0.24a.senna/myisam/mi_delete_table.c mysql-5.0.24a-win/myisam/mi_delete_table.c
 cp mysql-5.0.24a.senna/myisam/mi_info.c mysql-5.0.24a-win/myisam/mi_info.c
 cp mysql-5.0.24a.senna/myisam/mi_open.c mysql-5.0.24a-win/myisam/mi_open.c
 cp mysql-5.0.24a.senna/myisam/mi_rename.c mysql-5.0.24a-win/myisam/mi_rename.c
 cp mysql-5.0.24a.senna/myisam/myisam_ftdump.c mysql-5.0.24a-win/myisam/myisam_ftdump.c
 cp mysql-5.0.24a.senna/myisam/myisamchk.c mysql-5.0.24a-win/myisam/myisamchk.c
 cp mysql-5.0.24a.senna/myisam/myisamlog.c mysql-5.0.24a-win/myisam/myisamlog.c
 cp mysql-5.0.24a.senna/myisam/myisampack.c mysql-5.0.24a-win/myisam/myisampack.c
 cp mysql-5.0.24a.senna/sql/filesort.cc mysql-5.0.24a-win/sql/filesort.cpp
 cp mysql-5.0.24a.senna/sql/ha_myisam.cc mysql-5.0.24a-win/sql/ha_myisam.cpp
 cp mysql-5.0.24a.senna/sql/handler.h mysql-5.0.24a-win/sql/handler.h
 cp mysql-5.0.24a.senna/sql/item.h mysql-5.0.24a-win/sql/item.h
 cp mysql-5.0.24a.senna/sql/item_cmpfunc.cc mysql-5.0.24a-win/sql/item_cmpfunc.cpp
 cp mysql-5.0.24a.senna/sql/item_cmpfunc.h mysql-5.0.24a-win/sql/item_cmpfunc.h
 cp mysql-5.0.24a.senna/sql/item_func.cc mysql-5.0.24a-win/sql/item_func.cpp
 cp mysql-5.0.24a.senna/sql/item_func.h mysql-5.0.24a-win/sql/item_func.h
 cp mysql-5.0.24a.senna/sql/item_sum.cc mysql-5.0.24a-win/sql/item_sum.cpp
 cp mysql-5.0.24a.senna/sql/lex.h mysql-5.0.24a-win/sql/lex.h
 cp mysql-5.0.24a.senna/sql/lex_hash.h mysql-5.0.24a-win/sql/lex_hash.h
 cp mysql-5.0.24a.senna/sql/mysqld.cc mysql-5.0.24a-win/sql/mysqld.cpp
 cp mysql-5.0.24a.senna/sql/records.cc mysql-5.0.24a-win/sql/records.cpp
 cp mysql-5.0.24a.senna/sql/sql_class.h mysql-5.0.24a-win/sql/sql_class.h
 cp mysql-5.0.24a.senna/sql/sql_db.cc mysql-5.0.24a-win/sql/sql_db.cpp
 cp mysql-5.0.24a.senna/sql/sql_delete.cc mysql-5.0.24a-win/sql/sql_delete.cpp
 cp mysql-5.0.24a.senna/sql/sql_lex.h mysql-5.0.24a-win/sql/sql_lex.h
 cp mysql-5.0.24a.senna/sql/sql_select.cc mysql-5.0.24a-win/sql/sql_select.cpp
 cp mysql-5.0.24a.senna/sql/sql_show.cc mysql-5.0.24a-win/sql/sql_show.cpp
 cp mysql-5.0.24a.senna/sql/sql_table.cc mysql-5.0.24a-win/sql/sql_table.cpp
 cp mysql-5.0.24a.senna/sql/sql_yacc.cc mysql-5.0.24a-win/sql/sql_yacc.cpp
 cp mysql-5.0.24a.senna/sql/sql_yacc.h mysql-5.0.24a-win/sql/sql_yacc.h
 cp mysql-5.0.24a.senna/sql/structs.h mysql-5.0.24a-win/sql/structs.h

6. Modify Windows source code

Edit sprintf to my_sprintf in mi_delete_table.c and mi_rename.c.

Insert

#define ENABLE_SENNA 1

to config-win.h.

7. Make tarball by Windows source

Run below command and make source package for Windows

tar cvfz mysql-5.0.24-senna-win-src.tar.gz mysql-5.0.24-win

8. Build source package on Windows

Pass the source package to Windows and expand it.

Open mysql.dsw

Compile project mysqld, myisamchk, myisamlog, myisam_ftdump, myisampack by release solution format. Compile project mysqld by Debug, Max, Max nt, nt, and Release solution format.

In addition, you need to set up propaty of project mysqld, myisamchk, myisamlog, myisam_ftdump, and myisampack, while you compile above. Add senna.h to "additional include directory" and add "libsenna.lib" to "additional library".

9. Run these commands on Windows

If working directory is c:\mydoc\mysql-5.0.24-win and MySQL's installed directory is c:\mysql;

cd c:\mydoc\mysql-5.0.24-win
copy client_release\*.exe C:\mysql\bin
copy client_debug\mysqld.exe C:\mysql\bin\mysqld-debug.exe
xcopy scripts\*.* C:\mysql\scripts /E
xcopy share\*.* C:\mysql\share /E

If you also want to install libraries;

copy lib_debug\mysqlclient.lib C:\mysql\lib\debug
copy lib_debug\libmysql.* C:\mysql\lib\debug
copy lib_debug\zlib.* C:\mysql\lib\debug
copy lib_release\mysqlclient.lib C:\mysql\lib\opt
copy lib_release\libmysql.* C:\mysql\lib\opt
copy lib_release\zlib.* C:\mysql\lib\opt
copy include\*.h C:\mysql\include
copy libmysql\libmysql.def C:\mysql\include

If you want to install MySQL bench;

xcopy sql-bench\*.* C:\mysql\bench /E
生成時間: __qwik_page_generate_time__秒