Building MySQL from the Standard Source Distribution

You can build MySQL on Windows by using a combination of cmake and Microsoft Visual Studio .NET 2003 (7.1), Microsoft Visual Studio 2005 (8.0) or Microsoft Visual C++ 2005 Express Edition. You must have the appropriate Microsoft Platform SDK installed.


To compile from the source code using CMake you must use the standard source distribution (for example, mysql-5.0.96.tar.gz). You build from the same distribution as used to build MySQL on Unix, Linux and other platforms. Do not use the Windows Source distributions as they do not contain the necessary configuration script and other files.

Follow this procedure to build MySQL:

  1. If you are installing from a packaged source distribution, create a work directory (for example, C:\workdir), and unpack the source distribution there using WinZip or another Windows tool that can read .zip files. This directory is the work directory in the following instructions.

  2. If you are installing from a Bazaar tree, the root directory of that tree is the work directory in the following instructions.

  3. Using a command shell, navigate to the work directory and run the following command:

    C:\workdir>win\configure.js options

    If you have associated the .js file extension with an application such as a text editor, then you may need to use the following command to force configure.js to be executed as a script:

    C:\workdir>cscript win\configure.js options

    These options are available for configure.js:

    • WITH_INNOBASE_STORAGE_ENGINE: Enable the InnoDB storage engine.

    • WITH_PARTITION_STORAGE_ENGINE: Enable user-defined partitioning.

    • WITH_ARCHIVE_STORAGE_ENGINE: Enable the ARCHIVE storage engine.

    • WITH_BLACKHOLE_STORAGE_ENGINE: Enable the BLACKHOLE storage engine.

    • WITH_EXAMPLE_STORAGE_ENGINE: Enable the EXAMPLE storage engine.

    • WITH_FEDERATED_STORAGE_ENGINE: Enable the FEDERATED storage engine.

    • MYSQL_SERVER_SUFFIX=suffix: Server suffix, default none.

    • COMPILATION_COMMENT=comment: Server comment, default "Source distribution".

    • MYSQL_TCP_PORT=port: Server port, default 3306.

    • DISABLE_GRANT_OPTIONS: Disables the the --bootstrap, --skip-grant-tables, and --init-file options for mysqld. This option is available as of MySQL 5.0.36.

    For example (type the command on one line):

    C:\workdir>win\configure.js WITH_INNOBASE_STORAGE_ENGINE »
  4. From the work directory, execute the win\build-vs8.bat or win\build-vs71.bat file, depending on the version of Visual Studio you have installed. The script invokes CMake, which generates the mysql.sln solution file you will need to build MySQL using Visual Studio..

    You can also use win\build-vs8_x64.bat to build the 64-bit version of MySQL. However, you cannot build the 64-bit version with Visual Studio Express Edition. You must use Visual Studio 2005 (8.0) or higher.

  5. From the work directory, open the generated mysql.sln file with Visual Studio and select the proper configuration using the Configuration menu. The menu provides Debug, Release, RelwithDebInfo, MinRelInfo options. Then select Solution > Build to build the solution.

    The build process will take some time. Please be patient.

    Remember the configuration that you use in this step. It is important later when you run the test script because that script needs to know which configuration you used.

  6. You should test you build before installation. See Section, “Testing a Windows Source Build”.

  7. To install, use the instructions in Section, “Installing MySQL from a Source Build on Windows”.

User Comments
  Posted by Chris Calender on January 18, 2012
How to Build MySQL 5.5 from Source Code on Windows

Sign Up Login You must be logged in to post a comment.