2
2.5.10. Installing MySQL from Source on Windows
4
These instructions describe how to build binaries from source for
5
MySQL 5.1 on Windows. Instructions are provided for building
6
binaries from a standard source distribution or from the Bazaar
7
tree that contains the latest development source.
11
The instructions here are strictly for users who want to test
12
MySQL on Microsoft Windows from the latest source distribution or
13
from the Bazaar tree. For production use, we do not advise using a
14
MySQL server built by yourself from source. Normally, it is best
15
to use precompiled binary distributions of MySQL that are built
16
specifically for optimal performance on Windows by Sun
17
Microsystems, Inc. Instructions for installing binary
18
distributions are available in Section 2.5, "Installing MySQL on
21
To build MySQL on Windows from source, you must satisfy the
22
following system, compiler, and resource requirements:
24
* Windows 2000, Windows XP, or newer version.
25
Windows Vista is supported when using Visual Studio 2005
26
provided you have installed the following updates:
28
+ Microsoft Visual Studio 2005 Professional Edition - ENU
29
Service Pack 1 (KB926601)
30
(http://support.microsoft.com/?kbid=926601)
32
+ Security Update for Microsoft Visual Studio 2005
33
Professional Edition - ENU (KB937061)
34
(http://support.microsoft.com/?kbid=937061)
36
+ Update for Microsoft Visual Studio 2005 Professional
37
Edition - ENU (KB932232)
38
(http://support.microsoft.com/?kbid=932232)
40
* CMake, which can be downloaded from http://www.cmake.org.
41
After installing, modify your path to include the cmake
44
* Microsoft Visual C++ 2005 Express Edition, Visual Studio .Net
45
2003 (7.1), or Visual Studio 2005 (8.0) compiler system.
47
* If you are using Visual C++ 2005 Express Edition, you must
48
also install an appropriate Platform SDK. More information and
49
links to downloads for various Windows platforms is available
51
http://www.microsoft.com/downloads/details.aspx?familyid=0baf2
52
b35-c656-4969-ace8-e4c0c0716adb.
54
* If you are compiling from a Bazaar tree or making changes to
55
the parser, you need bison for Windows, which can be
57
http://gnuwin32.sourceforge.net/packages/bison.htm. Download
58
the package labeled "Complete package, excluding sources".
59
After installing the package, modify your path to include the
60
bison binary and ensure that this binary is accessible from
63
* Cygwin might be necessary if you want to run the test script
64
or package the compiled binaries and support files into a Zip
65
archive. (Cygwin is needed only to test or package the
66
distribution, not to build it.) Cygwin is available from
69
* 3GB to 5GB of disk space.
71
The exact system requirements for Visual Studio can be found here:
72
http://msdn.microsoft.com/vstudio/Previous/2003/sysreqs/default.as
74
http://msdn.microsoft.com/vstudio/products/sysreqs/default.aspx
76
You also need a MySQL source distribution for Windows, which can
79
* Obtain a source distribution packaged by Sun Microsystems,
80
Inc. These are available from http://dev.mysql.com/downloads/.
82
* Package a source distribution yourself from the latest Bazaar
83
developer source tree. For instructions on pulling the latest
84
source files, see Section 2.3.3, "Installing from the
85
Development Source Tree."
87
If you find something not working as expected, or you have
88
suggestions about ways to improve the current build process on
89
Windows, please send a message to the win32 mailing list. See
90
Section 1.6.1, "MySQL Mailing Lists."
92
2.5.10.1. Building MySQL from Source Using CMake and Visual Studio
94
You can build MySQL on Windows by using a combination of cmake and
95
Microsoft Visual Studio .NET 2003 (7.1), Microsoft Visual Studio
96
2005 (8.0), Microsoft Visual Studio 2008 (9.0) or Microsoft Visual
97
C++ 2005 Express Edition. You must have the appropriate Microsoft
98
Platform SDK installed.
102
To compile from the source code on Windows you must use the
103
standard source distribution (for example, mysql-5.1.45.tar.gz).
104
You build from the same distribution as used to build MySQL on
105
Unix, Linux and other platforms. Do not use the Windows Source
106
distributions as they do not contain the necessary configuration
107
script and other files.
109
Follow this procedure to build MySQL:
111
1. If you are installing from a packaged source distribution,
112
create a work directory (for example, C:\workdir), and unpack
113
the source distribution there using WinZip or another Windows
114
tool that can read .zip files. This directory is the work
115
directory in the following instructions.
118
You must run the commands in the win directory from the
119
top-level source directory. Do not change into the win
120
directory, as the commands will not be executed correctly.
122
2. Start a command shell. If you have not configured the PATH and
123
other environment variables for all command shells, you may be
124
able to start a command shell from the Start Menu within the
125
Windows Visual Studio menu that contains the necessary
128
3. Within the command shell, navigate to the work directory and
129
run the following command:
130
C:\workdir>win\configure.js options
131
If you have associated the .js file extension with an
132
application such as a text editor, then you may need to use
133
the following command to force configure.js to be executed as
135
C:\workdir>cscript win\configure.js options
136
These options are available for configure.js:
138
+ WITH_INNOBASE_STORAGE_ENGINE: Enable the InnoDB storage
141
+ WITH_PARTITION_STORAGE_ENGINE: Enable user-defined
144
+ WITH_ARCHIVE_STORAGE_ENGINE: Enable the ARCHIVE storage
147
+ WITH_BLACKHOLE_STORAGE_ENGINE: Enable the BLACKHOLE
150
+ WITH_EXAMPLE_STORAGE_ENGINE: Enable the EXAMPLE storage
153
+ WITH_FEDERATED_STORAGE_ENGINE: Enable the FEDERATED
156
+ WITH_NDBCLUSTER_STORAGE_ENGINE (experimental): Enable the
157
NDBCLUSTER storage engine in the MySQL server; cause
158
binaries for the MySQL Cluster management and data node,
159
management client, and other programs to be built.
160
This option is supported only in MySQL Cluster NDB 7.0
161
(NDBCLUSTER storage engine versions 6.4.0 and later)
162
using the MySQL Cluster sources. It cannot be used to
163
enable clustering support in other MySQL source trees or
166
+ MYSQL_SERVER_SUFFIX=suffix: Server suffix, default none.
168
+ COMPILATION_COMMENT=comment: Server comment, default
169
"Source distribution".
171
+ MYSQL_TCP_PORT=port: Server port, default 3306.
173
+ DISABLE_GRANT_OPTIONS: Disables the --bootstrap,
174
--skip-grant-tables, and --init-file options for mysqld.
175
This option is available as of MySQL 5.1.15.
176
For example (type the command on one line):
177
C:\workdir>win\configure.js WITH_INNOBASE_STORAGE_ENGINE
178
WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro
180
4. From the work directory, execute the win\build-vs9.bat
181
(Windows Visual Studio 2008), win\build-vs8.bat (Windows
182
Visual Studio 2005), or win\build-vs71.bat (Windows Visual
183
Stidion 2003) script, depending on the version of Visual
184
Studio you have installed. The script invokes CMake, which
185
generates the mysql.sln solution file.
186
You can also use the corresponding 64-bit file (for example
187
win\build-vs8_x64.bat or win\build-vs9_x64.bat) to build the
188
64-bit version of MySQL. However, you cannot build the 64-bit
189
version with Visual Studio Express Edition. You must use
190
Visual Studio 2005 (8.0) or higher.
192
5. From the work directory, open the generated mysql.sln file
193
with Visual Studio and select the proper configuration using
194
the Configuration menu. The menu provides Debug, Release,
195
RelwithDebInfo, MinRelInfo options. Then select Solution >
196
Build to build the solution.
197
Remember the configuration that you use in this step. It is
198
important later when you run the test script because that
199
script needs to know which configuration you used.
201
6. Test the server. The server built using the preceding
202
instructions expects that the MySQL base directory and data
203
directory are C:\mysql and C:\mysql\data by default. If you
204
want to test your server using the source tree root directory
205
and its data directory as the base directory and data
206
directory, you need to tell the server their path names. You
207
can either do this on the command line with the --basedir and
208
--datadir options, or by placing appropriate options in an
209
option file. (See Section 4.2.3.3, "Using Option Files.") If
210
you have an existing data directory elsewhere that you want to
211
use, you can specify its path name instead.
212
When the server is running in standalone fashion or as a
213
service based on your configuration, try to connect to it from
214
the mysql interactive command-line utility.
215
You can also run the standard test script, mysql-test-run.pl.
216
This script is written in Perl, so you'll need either Cygwin
217
or ActiveState Perl to run it. You may also need to install
218
the modules required by the script. To run the test script,
219
change location into the mysql-test directory under the work
220
directory, set the MTR_VS_CONFIG environment variable to the
221
configuration you selected earlier (or use the --vs-config
222
option), and invoke mysql-test-run.pl. For example (using
223
Cygwin and the bash shell):
225
shell> export MTR_VS_CONFIG=debug
226
shell> ./mysql-test-run.pl --force --timer
227
shell> ./mysql-test-run.pl --force --timer --ps-protocol
229
When you are satisfied that the programs you have built are
230
working correctly, stop the server. Now you can install the
231
distribution. One way to do this is to use the make_win_bin_dist
232
script in the scripts directory of the MySQL source distribution
233
(see Section 4.4.2, "make_win_bin_dist --- Package MySQL
234
Distribution as ZIP Archive"). This is a shell script, so you must
235
have Cygwin installed if you want to use it. It creates a Zip
236
archive of the built executables and support files that you can
237
unpack in the location at which you want to install MySQL.
239
It is also possible to install MySQL by copying directories and
242
1. Create the directories where you want to install MySQL. For
243
example, to install into C:\mysql, use these commands:
245
C:\> mkdir C:\mysql\bin
246
C:\> mkdir C:\mysql\data
247
C:\> mkdir C:\mysql\share
248
C:\> mkdir C:\mysql\scripts
249
If you want to compile other clients and link them to MySQL,
250
you should also create several additional directories:
251
C:\> mkdir C:\mysql\include
252
C:\> mkdir C:\mysql\lib
253
C:\> mkdir C:\mysql\lib\debug
254
C:\> mkdir C:\mysql\lib\opt
255
If you want to benchmark MySQL, create this directory:
256
C:\> mkdir C:\mysql\sql-bench
257
Benchmarking requires Perl support. See Section 2.15, "Perl
260
2. From the work directory, copy into the C:\mysql directory the
261
following files and directories:
263
C:\workdir> mkdir C:\mysql
264
C:\workdir> mkdir C:\mysql\bin
265
C:\workdir> copy client\Release\*.exe C:\mysql\bin
266
C:\workdir> copy sql\Release\mysqld.exe C:\mysql\bin\mysqld.exe
267
C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
268
C:\workdir> xcopy share\*.* C:\mysql\share /E
269
If you want to compile other clients and link them to MySQL,
270
you should also copy several libraries and header files:
271
C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\debug
272
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\debug
273
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\debug
274
C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\opt
275
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\opt
276
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\opt
277
C:\workdir> copy include\*.h C:\mysql\include
278
C:\workdir> copy libmysql\libmysql.def C:\mysql\include
281
If you have compiled a Debug, rather than Release solution,
282
you can replace Release with Debug in the source file names
284
If you want to benchmark MySQL, you should also do this:
285
C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E
287
After installation, set up and start the server in the same way as
288
for binary Windows distributions. This includes creating the
289
system tables by running mysql_install_db. For more information,
290
see Section 2.5, "Installing MySQL on Windows."