| 1 |
2.4.15.6 Installing MySQL from Source on Windows |
| 2 |
................................................ |
| 3 |
|
| 4 |
* Menu: |
| 5 |
|
| 6 |
* windows-source-build-cmake:: Building MySQL from the Standard Source Distribution |
| 7 |
* windows-vc-plus-plus-build:: Building MySQL from a Windows Source Distribution |
| 8 |
* windows-source-install:: Installing MySQL from a Source Build on Windows |
| 9 |
* windows-source-testbuild:: Testing a Windows Source Build |
| 10 |
* windows-bitkeeper-build:: Creating a Windows Source Package from the BitKeeper Repository |
| 11 |
|
| 12 |
This section does not apply to MySQL Enterprise Server users. |
| 13 |
|
| 14 |
These instructions describe how to build binaries from source for MySQL |
| 15 |
5.0 on Windows. Instructions are provided for building binaries from a |
| 16 |
standard source distribution or from the BitKeeper tree that contains |
| 17 |
the latest development source. |
| 18 |
|
| 19 |
*Note*: |
| 20 |
|
| 21 |
The instructions here are strictly for users who want to test MySQL on |
| 22 |
Microsoft Windows from the latest source distribution or from the |
| 23 |
BitKeeper tree. For production use, MySQL AB does not advise using a |
| 24 |
MySQL server built by yourself from source. Normally, it is best to |
| 25 |
use precompiled binary distributions of MySQL that are built |
| 26 |
specifically for optimal performance on Windows by MySQL AB. |
| 27 |
Instructions for installing binary distributions are available in *note |
| 28 |
windows-installation::. |
| 29 |
|
| 30 |
To build MySQL on Windows from source, you must satisfy the following |
| 31 |
system, compiler, and resource requirements: |
| 32 |
|
| 33 |
* Windows 2000, Windows XP, or newer version. Windows Vista is not |
| 34 |
supported until Microsoft certifies Visual Studio 2005 on Vista. |
| 35 |
|
| 36 |
* To build from the standard source distribution, you will need |
| 37 |
CMake, which can be downloaded from `http://www.cmake.org'. After |
| 38 |
installing, modify your path to include the `cmake' binary. |
| 39 |
|
| 40 |
* Microsoft Visual C++ 2005 Express Edition, Visual Studio .Net 2003 |
| 41 |
(7.1), or Visual Studio 2005 (8.0) compiler system. |
| 42 |
|
| 43 |
* If you are using Visual C++ 2005 Express Edition, you must also |
| 44 |
install an appropriate Platform SDK. More information and links to |
| 45 |
downloads for various Windows platforms is available from |
| 46 |
`http://www.microsoft.com/downloads/details.aspx?familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb/'. |
| 47 |
|
| 48 |
* If you are compiling from a BitKeeper tree or making changes to |
| 49 |
the parser, you need `bison' for Windows, which can be downloaded |
| 50 |
from `http://gnuwin32.sourceforge.net/packages/bison.htm'. |
| 51 |
Download the package labeled `Complete package, excluding |
| 52 |
sources'. After installing the package, modify your path to |
| 53 |
include the `bison' binary and ensure that this binary is |
| 54 |
accessible from Visual Studio. |
| 55 |
|
| 56 |
* Cygwin might be necessary if you want to run the test script or |
| 57 |
package the compiled binaries and support files into a Zip |
| 58 |
archive. (Cygwin is needed only to test or package the |
| 59 |
distribution, not to build it.) Cygwin is available from |
| 60 |
`http://cygwin.com'. |
| 61 |
|
| 62 |
* 3GB to 5GB of disk space. |
| 63 |
|
| 64 |
The exact system requirements can be found here: |
| 65 |
`http://msdn.microsoft.com/vstudio/Previous/2003/sysreqs/default.aspx' |
| 66 |
and `http://msdn.microsoft.com/vstudio/products/sysreqs/default.aspx' |
| 67 |
|
| 68 |
There are three solutions available for building from the source code |
| 69 |
on Windows: |
| 70 |
|
| 71 |
* Build from the standard MySQL source distribution. For this you |
| 72 |
will need CMake and Visual C++ Express Edition or Visual Studio. |
| 73 |
Using this method you can select the storage engines that are |
| 74 |
included in your build. To use this method, see *note |
| 75 |
windows-source-build-cmake::. |
| 76 |
|
| 77 |
* Build from the MySQL Windows source distribution. The Windows |
| 78 |
source distribution includes ready-made Visual Studio solution |
| 79 |
files that enable support for all storage engines (except `NDB'). |
| 80 |
To build using using method you only need Visual C++ Express |
| 81 |
Edition or Visual Studio. To use this method, see *note |
| 82 |
windows-vc-plus-plus-build::. |
| 83 |
|
| 84 |
* Build directly from the BitKeeper source repository. For this you |
| 85 |
will need CMake, Visual C++ Express Edition or Visual Studio, and |
| 86 |
`bison'. For this method you need to create the distribution on a |
| 87 |
Unix system and then copy the generated files to your Windows build |
| 88 |
environment. To use this method, see *note |
| 89 |
windows-bitkeeper-build::. |
| 90 |
|
| 91 |
If you find something not working as expected, or you have suggestions |
| 92 |
about ways to improve the current build process on Windows, please send |
| 93 |
a message to the `win32' mailing list. See *note mailing-lists::. |
| 94 |
|
| 95 |
File: manual.info, Node: windows-source-build-cmake, Next: windows-vc-plus-plus-build, Prev: windows-source-build, Up: windows-source-build |
| 96 |
|
| 97 |
2.4.15.7 Building MySQL from the Standard Source Distribution |
| 98 |
............................................................. |
| 99 |
|
| 100 |
This section does not apply to MySQL Enterprise Server users. |
| 101 |
|
| 102 |
You can build MySQL on Windows by using a combination of `cmake' and |
| 103 |
Microsoft Visual Studio .NET 2003 (7.1), Micrsofot Visual Studio 2005 |
| 104 |
(8.0) or Microsoft Visual C++ 2005 Express Edition. You must have the |
| 105 |
appropriate Microsoft Platform SDK installed. |
| 106 |
|
| 107 |
*Note*: |
| 108 |
|
| 109 |
To compile from the source code usin CMake you must use the standard |
| 110 |
source distribution (for example, `mysql-5.0.45.tar.gz'). You build |
| 111 |
from the same distribution as used to build MySQL on Unix, Linux and |
| 112 |
other platforms. Do _not_ use the Windows Source distributions as they |
| 113 |
do not contain the necessary configuration script and other files. |
| 114 |
|
| 115 |
Follow this procedure to build MySQL: |
| 116 |
|
| 117 |
1. If you are installing from a packaged source distribution, create |
| 118 |
a work directory (for example, `C:\workdir'), and unpack the source |
| 119 |
distribution there using `WinZip' or another Windows tool that can |
| 120 |
read `.zip' files. This directory is the work directory in the |
| 121 |
following instructions. |
| 122 |
|
| 123 |
2. If you are installing from a BitKeeper tree, the root directory of |
| 124 |
that tree is the work directory in the following instructions. |
| 125 |
|
| 126 |
3. Using a command shell, navigate to the work directory and run the |
| 127 |
following command: |
| 128 |
|
| 129 |
C:\workdir>win\configure OPTIONS |
| 130 |
|
| 131 |
These options are available: |
| 132 |
|
| 133 |
* `WITH_INNOBASE_STORAGE_ENGINE': Enable the `InnoDB' storage |
| 134 |
engine. |
| 135 |
|
| 136 |
* `WITH_PARTITION_STORAGE_ENGINE': Enable user-defined |
| 137 |
partitioning. |
| 138 |
|
| 139 |
* `WITH_ARCHIVE_STORAGE_ENGINE': Enable the `ARCHIVE' storage |
| 140 |
engine. |
| 141 |
|
| 142 |
* `WITH_BLACKHOLE_STORAGE_ENGINE': Enable the `BLACKHOLE' |
| 143 |
storage engine. |
| 144 |
|
| 145 |
* `WITH_EXAMPLE_STORAGE_ENGINE': Enable the `EXAMPLE' storage |
| 146 |
engine. |
| 147 |
|
| 148 |
* `WITH_FEDERATED_STORAGE_ENGINE': Enable the `FEDERATED' |
| 149 |
storage engine. |
| 150 |
|
| 151 |
* `__NT__': Enable support for named pipes. |
| 152 |
|
| 153 |
* `MYSQL_SERVER_SUFFIX=SUFFIX': Server suffix, default none. |
| 154 |
|
| 155 |
* `COMPILATION_COMMENT=COMMENT': Server comment, default |
| 156 |
"Source distribution". |
| 157 |
|
| 158 |
* `MYSQL_TCP_PORT=PORT': Server port, default 3306. |
| 159 |
|
| 160 |
* `DISABLE_GRANT_OPTIONS': Disables the the `--bootstrap', |
| 161 |
`--skip-grant-tables', and `--init-file' options for |
| 162 |
`mysqld'. This option is available as of MySQL 5.0.36. |
| 163 |
|
| 164 |
For example (type the command on one line): |
| 165 |
|
| 166 |
C:\workdir>win\configure WITH_INNOBASE_STORAGE_ENGINE �� |
| 167 |
WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro |
| 168 |
|
| 169 |
4. From the work directory, execute the `win\build-vs8.bat' or |
| 170 |
`win\build-vs71.bat' file, depending on the version of Visual |
| 171 |
Studio you have installed. The script invokes CMake, which |
| 172 |
generates the `mysql.sln' solution file you will need to build |
| 173 |
MySQL using Visual Studio.. |
| 174 |
|
| 175 |
You can also use `win\build-vs8_x64.bat' to build the 64-bit |
| 176 |
version of MySQL. However, you cannot build the 64-bit version |
| 177 |
with Visual Studio Express Edition. You must use Visual Studio |
| 178 |
2005 (8.0) or higher. |
| 179 |
|
| 180 |
5. From the work directory, open the generated `mysql.sln' file with |
| 181 |
Visual Studio and select the proper configuration using the |
| 182 |
`Configuration' menu. The menu provides `Debug', `Release', |
| 183 |
`RelwithDebInfo', `MinRelInfo' options. Then select `Solution' > |
| 184 |
`Build' to build the solution. |
| 185 |
|
| 186 |
The build process will take some time. Please be patient. |
| 187 |
|
| 188 |
Remember the configuration that you use in this step. It is |
| 189 |
important later when you run the test script because that script |
| 190 |
needs to know which configuration you used. |
| 191 |
|
| 192 |
6. You should test you build before installation. See *note |
| 193 |
windows-source-testbuild::. |
| 194 |
|
| 195 |
7. To install, use the instructions in *note windows-source-install::. |
| 196 |
|
| 197 |
File: manual.info, Node: windows-vc-plus-plus-build, Next: windows-source-install, Prev: windows-source-build-cmake, Up: windows-source-build |
| 198 |
|
| 199 |
2.4.15.8 Building MySQL from a Windows Source Distribution |
| 200 |
.......................................................... |
| 201 |
|
| 202 |
This section does not apply to MySQL Enterprise Server users. |
| 203 |
|
| 204 |
The Windows source distribution includes the necessary solution file |
| 205 |
and the `vcproj' files required to build each component. Using this |
| 206 |
method you are not able to select the storage engines that are included |
| 207 |
in your build. |
| 208 |
|
| 209 |
*Note*: |
| 210 |
|
| 211 |
VC++ workspace files for MySQL 4.1 and above are compatible with |
| 212 |
Microsoft Visual Studio 7.1 and tested by MySQL AB staff before each |
| 213 |
release. |
| 214 |
|
| 215 |
Follow this procedure to build MySQL: |
| 216 |
|
| 217 |
1. Create a work directory (for example, `C:\workdir'). |
| 218 |
|
| 219 |
2. Unpack the source distribution in the aforementioned directory |
| 220 |
using `WinZip' or another Windows tool that can read `.zip' files. |
| 221 |
|
| 222 |
3. Start Visual Studio .Net 2003 (7.1). |
| 223 |
|
| 224 |
4. From the `File' menu, select `Open Solution...'. |
| 225 |
|
| 226 |
5. Open the `mysql.sln' solution you find in the work directory. |
| 227 |
|
| 228 |
6. From the `Build' menu, select `Configuration Manager...'. |
| 229 |
|
| 230 |
7. In the `Active Solution Configuration' pop-up menu, select the |
| 231 |
configuration to use. You likely want to use one of `nt' (normal |
| 232 |
server), `Max nt' (more engines and features), or `Debug' |
| 233 |
configuration. |
| 234 |
|
| 235 |
8. From the `Build' menu, select `Build Solution'. |
| 236 |
|
| 237 |
9. Debug versions of the programs and libraries are placed in the |
| 238 |
`client_debug' and `lib_debug' directories. Release versions of |
| 239 |
the programs and libraries are placed in the `client_release' and |
| 240 |
`lib_release' directories. |
| 241 |
|
| 242 |
10. You should test you build before installation. See *note |
| 243 |
windows-source-testbuild::. |
| 244 |
|
| 245 |
11. To install, use the instructions in *note windows-source-install::. |
| 246 |
|
| 247 |
File: manual.info, Node: windows-source-install, Next: windows-source-testbuild, Prev: windows-vc-plus-plus-build, Up: windows-source-build |
| 248 |
|
| 249 |
2.4.15.9 Installing MySQL from a Source Build on Windows |
| 250 |
........................................................ |
| 251 |
|
| 252 |
When you are satisfied that the program you have built is working |
| 253 |
correctly, stop the server. Now you can install the distribution. There |
| 254 |
are two ways to do this, either by using the supplied installation |
| 255 |
script or by copying the files individually by hand. |
| 256 |
|
| 257 |
To use the script method you must have Cygwin installed as the script |
| 258 |
is a Shell script. To execute the installation process, run the |
| 259 |
`make_win_bin_dist' script in the `scripts' directory of the MySQL |
| 260 |
source distribution (see *note make-win-bin-dist::). This is a shell |
| 261 |
script, so you must have Cygwin installed if you want to use it. It |
| 262 |
creates a Zip archive of the built executables and support files that |
| 263 |
you can unpack to your desired installation location. |
| 264 |
|
| 265 |
It is also possible to install MySQL by copying directories and files |
| 266 |
manually: |
| 267 |
|
| 268 |
1. Create the directories where you want to install MySQL. For |
| 269 |
example, to install into `C:\mysql', use these commands: |
| 270 |
|
| 271 |
C:\> mkdir C:\mysql |
| 272 |
C:\> mkdir C:\mysql\bin |
| 273 |
C:\> mkdir C:\mysql\data |
| 274 |
C:\> mkdir C:\mysql\share |
| 275 |
C:\> mkdir C:\mysql\scripts |
| 276 |
|
| 277 |
If you want to compile other clients and link them to MySQL, you |
| 278 |
should also create several additional directories: |
| 279 |
|
| 280 |
C:\> mkdir C:\mysql\include |
| 281 |
C:\> mkdir C:\mysql\lib |
| 282 |
C:\> mkdir C:\mysql\lib\debug |
| 283 |
C:\> mkdir C:\mysql\lib\opt |
| 284 |
|
| 285 |
If you want to benchmark MySQL, create this directory: |
| 286 |
|
| 287 |
C:\> mkdir C:\mysql\sql-bench |
| 288 |
|
| 289 |
Benchmarking requires Perl support. See *note perl-support::. |
| 290 |
|
| 291 |
2. From the work directory, copy into the `C:\mysql' directory the |
| 292 |
following directories: |
| 293 |
|
| 294 |
C:\> cd \workdir |
| 295 |
C:\workdir> copy client_release\*.exe C:\mysql\bin |
| 296 |
C:\workdir> copy client_debug\mysqld.exe C:\mysql\bin\mysqld-debug.exe |
| 297 |
C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E |
| 298 |
C:\workdir> xcopy share\*.* C:\mysql\share /E |
| 299 |
|
| 300 |
If you want to compile other clients and link them to MySQL, you |
| 301 |
should also copy several libraries and header files: |
| 302 |
|
| 303 |
C:\workdir> copy lib_debug\mysqlclient.lib C:\mysql\lib\debug |
| 304 |
C:\workdir> copy lib_debug\libmysql.* C:\mysql\lib\debug |
| 305 |
C:\workdir> copy lib_debug\zlib.* C:\mysql\lib\debug |
| 306 |
C:\workdir> copy lib_release\mysqlclient.lib C:\mysql\lib\opt |
| 307 |
C:\workdir> copy lib_release\libmysql.* C:\mysql\lib\opt |
| 308 |
C:\workdir> copy lib_release\zlib.* C:\mysql\lib\opt |
| 309 |
C:\workdir> copy include\*.h C:\mysql\include |
| 310 |
C:\workdir> copy libmysql\libmysql.def C:\mysql\include |
| 311 |
|
| 312 |
If you want to benchmark MySQL, you should also do this: |
| 313 |
|
| 314 |
C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E |
| 315 |
|
| 316 |
After installation, set up and start the server in the same way as for |
| 317 |
binary Windows distributions. See *note windows-installation::. |
| 318 |
|
| 319 |
File: manual.info, Node: windows-source-testbuild, Next: windows-bitkeeper-build, Prev: windows-source-install, Up: windows-source-build |
| 320 |
|
| 321 |
2.4.15.10 Testing a Windows Source Build |
| 322 |
........................................ |
| 323 |
|
| 324 |
You should test the server that you have built from source before using |
| 325 |
the distribution. |
| 326 |
|
| 327 |
To test the server you need to run the built `mysqld'. By default, |
| 328 |
using the source build examples, the MySQL base directory and data |
| 329 |
directory are `C:\mysql' and `C:\mysql\data'. If you want to test your |
| 330 |
server using the source tree root directory and its data directory as |
| 331 |
the base directory and data directory, you need to tell the server |
| 332 |
their pathnames. You can either do this on the command line with the |
| 333 |
`--basedir' and `--datadir' options, or by placing appropriate options |
| 334 |
in an option file. (See *note option-files::.) If you have an existing |
| 335 |
data directory elsewhere that you want to use, you can specify its |
| 336 |
pathname instead. |
| 337 |
|
| 338 |
When the server is running in standalone fashion or as a service based |
| 339 |
on your configuration, try to connect to it from the `mysql' |
| 340 |
interactive command-line utility. |
| 341 |
|
| 342 |
You can also run the standard test script, `mysql-test-run.pl'. This |
| 343 |
script is written in Perl, so you'll need either Cygwin or ActiveState |
| 344 |
Perl to run it. You may also need to install the modules required by |
| 345 |
the script. To run the test script, change location into the |
| 346 |
`mysql-test' directory under the work directory, set the `MTR_VS_CONFIG' |
| 347 |
environment variable to the configuration you selected earlier (or use |
| 348 |
the `--vs-config' option), and invoke `mysql-test-run.pl'. For example |
| 349 |
(using Cygwin and the `bash' shell): |
| 350 |
|
| 351 |
shell> `cd mysql-test' |
| 352 |
shell> `export MTS_VS_CONFIG=debug' |
| 353 |
shell> `./mysqltest-run.pl --force --timer' |
| 354 |
shell> `./mysqltest-run.pl --force --timer --ps-protocol' |
| 355 |
|
| 356 |
File: manual.info, Node: windows-bitkeeper-build, Prev: windows-source-testbuild, Up: windows-source-build |
| 357 |
|
| 358 |
2.4.15.11 Creating a Windows Source Package from the BitKeeper Repository |
| 359 |
......................................................................... |
| 360 |
|
| 361 |
This section does not apply to MySQL Enterprise Server users. |
| 362 |
|
| 363 |
To create a Windows source package from the current BitKeeper source |
| 364 |
tree, use the instructions here. This procedure must be performed on a |
| 365 |
system running a Unix or Unix-like operating system because some of the |
| 366 |
configuration and build steps require tools that work only on Unix. For |
| 367 |
example, the following procedure is known to work well on Linux. |
| 368 |
|
| 369 |
1. Copy the BitKeeper source tree for MySQL 5.0. For instructions on |
| 370 |
how to do this, see *note installing-source-tree::. |
| 371 |
|
| 372 |
2. Configure and build the distribution so that you have a server |
| 373 |
binary to work with. One way to do this is to run the following |
| 374 |
command in the top-level directory of your source tree: |
| 375 |
|
| 376 |
shell> ./BUILD/compile-pentium-max |
| 377 |
|
| 378 |
3. After making sure that the build process completed successfully, |
| 379 |
run the following utility script from top-level directory of your |
| 380 |
source tree: |
| 381 |
|
| 382 |
shell> ./scripts/make_win_src_distribution |
| 383 |
|
| 384 |
This script creates a Windows source package to be used on your |
| 385 |
Windows system. You can supply different options to the script |
| 386 |
based on your needs. See *note make-win-src-distribution::, for a |
| 387 |
list of allowable options. |
| 388 |
|
| 389 |
By default, `make_win_src_distribution' creates a Zip-format |
| 390 |
archive with the name `mysql-VERSION-win-src.zip', where VERSION |
| 391 |
represents the version of your MySQL source tree. |
| 392 |
|
| 393 |
4. Copy or upload the Windows source package that you have just |
| 394 |
created to your Windows machine. To compile it, use the |
| 395 |
instructions in *note windows-vc-plus-plus-build::. |
| 396 |
|
| 397 |
File: manual.info, Node: windows-client-compiling, Prev: windows-source-build, Up: installing-source |
| 398 |
|
| 399 |
2.4.15.12 Compiling MySQL Clients on Windows |
| 400 |
............................................ |
| 401 |
|
| 402 |
This section does not apply to MySQL Enterprise Server users. |
| 403 |
|
| 404 |
In your source files, you should include `my_global.h' before `mysql.h': |
| 405 |
|
| 406 |
#include <my_global.h> |
| 407 |
#include <mysql.h> |
| 408 |
|
| 409 |
`my_global.h' includes any other files needed for Windows compatibility |
| 410 |
(such as `windows.h') if you compile your program on Windows. |
| 411 |
|
| 412 |
You can either link your code with the dynamic `libmysql.lib' library, |
| 413 |
which is just a wrapper to load in `libmysql.dll' on demand, or link |
| 414 |
with the static `mysqlclient.lib' library. |
| 415 |
|
| 416 |
The MySQL client libraries are compiled as threaded libraries, so you |
| 417 |
should also compile your code to be multi-threaded. |
| 418 |
|