These instructions describe how to build MySQL binaries from source for versions 4.1 and above on Windows. Instructions are provided for building binaries from a standard source distribution or from the BitKeeper tree that contains the latest development source.
Note: The instructions in this document are strictly for users who want to test MySQL on Windows from the latest source distribution or from the BitKeeper tree. For production use, MySQL AB does not advise using a MySQL server built by yourself from source. Normally, it is best to use precompiled binary distributions of MySQL that are built specifically for optimal performance on Windows by MySQL AB. Instructions for installing a binary distributions are available at Windows installation.
To build MySQL on Windows from source, you need the following compiler and resources available on your Windows system:
VC++ 6.0 compiler (updated with 4 or 5 SP and pre-processor package). The pre-processor package is necessary for the macro assembler. More details at: http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/faq.aspx.
Approximately 45 MB disk space.
64 MB RAM.
You'll also need a MySQL source distribution for Windows. There are two ways you can get a source distribution for MySQL version 4.1 and above:
Obtain a source distribution packaged by MySQL AB for the particular version of MySQL in which you are interested. Prepackaged source distributions are available for released versions of MySQL and can be obtained from http://www.mysql.com/downloads/.
You can package a source distribution yourself from the latest BitKeeper developer source tree. If you plan to do this, you must create the package on a Unix system and then transfer it to your Windows system. (The reason for this is that some of the configuration and build steps require tools that work only on Unix.) The BitKeeper approach thus requires:
A system running Unix, or a Unix-like system such as Linux.
BitKeeper 3.0 installed on that system. You can obtain BitKeeper from http://www.bitkeeper.com/.
If you are using a Windows source distribution, you can go directly to Windows VC++ Build. To build from the BitKeeper tree, proceed to Windows BitKeeper Build.
If you find something not working as expected, or you have suggestions about ways to improve the current build process on Windows, please send a message to the win32 mailing list. See Mailing-list.
Note: MySQL 4.1 and above VC++ workspace files are compatible with Microsoft Visual Studio 6.0 and above(7.0/.NET) editions and tested by MySQL AB staff before each release.
Follow this procedure to build MySQL:
Create a work directory (for example, workdir).
Unpack the source distribution in the aforementioned directory using WinZip or other Windows tools that can read .zip files.
Start the VC++ 6.0 compiler.
In the File menu, select Open Workspace.
Open the mysql.dsw workspace you find in the work directory.
From the Build menu, select the Set Active Configuration menu.
Click over the screen selecting mysqld - Win32 Debug and click OK.
Press F7 to begin the build of the debug server, libraries, and some client applications.
Compile the release versions that you want, in the same way.
Debug versions of the programs and libraries are placed in the client_debug and lib_debug directories. Release versions of the programs and libraries are placed in the client_release and lib_release directories. Note that if you want to build both debug and release versions, you can select the ``build all'' option from the Build menu.
Test the server. The server built using the preceding instructions will expect that the MySQL base directory and data directory are C:\mysql and C:\mysql\data by default. If you want to test your server using the source tree root directory and its data directory as the base directory and data directory, you will need to tell the server their pathnames. You can either do this on the command line with the --basedir and --datadir options, or place appropriate options in an option file (C:\my.cnf or the my.ini file in your Windows directory). If you have an existing data directory elsewhere that you want to use, you can specify its pathname instead.
Start your server from the client_release or client_debug directory, depending on which server you want to use. The general server startup instructions are at Windows installation. You'll need to to adapt the instructions appropriately if you want to use a different base directory or data directory.
When the server is running in standalone fashion or as a service based on your configuration, try to connect to it from the mysql interactive command line utility that exists in your client_release or client_debug directory.
When you are satisifed that the programs you have built are working correctly, stop the server. Then install MySQL as follows:
Create the directories where you want to install MySQL. For example, to install into C:\mysql, use these commands:
C: mkdir \mysql mkdir \mysql\bin mkdir \mysql\data mkdir \mysql\share mkdir \mysql\scripts
If you want to compile other clients and link them to MySQL, you should also create several additional directories:
mkdir \mysql\include mkdir \mysql\lib mkdir \mysql\lib\debug mkdir \mysql\lib\opt
If you want to benchmark MySQL, create this directory:
mkdir \mysql\sql-bench
Benchmarking requires Perl support.
From the workdir directory, copy into the C:\mysql directory the following directories:
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 want to compile other clients and link them to MySQL, you should also copy several libraries and header files:
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 benchmark MySQL, you should also do this:
xcopy sql-bench\*.* C:\mysql\bench /E
Set up and start the server in the same way as for the binary Windows distribution. See Windows installation.
To create a Windows source package from the current BitKeeper source tree, use the following instructions. Please note that this procedure must be performed on a system running a Unix or Unix-like operating system. (The procedure is known to work well on Linux, for example.)
Clone the BitKeeper source tree for MySQL (version 4.1 or above, as desired). For more information how to clone the source tree, see the instructions at Installing source tree.
Configure and build the distribution so that you have a server binary to work with. One way to do this is to run the following command in the top-level directory of your source tree:
shell> ./BUILD/compile-pentium-max
After making sure that the build process completed successfully, run the following utility script from top-level directory of your source tree:
shell> ./scripts/make_win_src_distribution
This script creates a Windows source package, to be used on your Windows system. You can supply different options to the script based on your needs. It accepts the following options:
--debug Print information about script operations, do not create package --tmp Specify the temporary location --suffix Suffix name for the package --dirname Directory name to copy files (intermediate) --silent Do not print verbose list of files processed --tar Create tar.gz package instead of .zip package --help Show this help message
By default, make_win_src_distribution creates a zipped archive with the name mysql-VERSION-win-src.zip, where VERSION represents the version of your MySQL source tree.
Copy or upload to your Windows machine the Windows source package that you have just created. To compile it, use the instructions in Windows VC++ Build.