How to Build and Install MariaDB From Source on Windows


Knowing that MariaDB in the simplest terms, is an alternative to MySQL database server; the world’s most popular open source relational database management system. MariaDb has its source code made publicly available from Launchpad, MariaDB remains an open and free fork of MySQL database. MariaDB runs on both Linux and Unix based operating systems as well as Windows. This tutorial shows you how to get MariaDB up and running from the source code on Windows.

To be able to build and install MariaDB you need the right tools to be able to get the Job done. Before we start you need to make sure you have the following tools and sources.

  • CMake
  • C++ Compiler
  • Bison
  • MariaDB Source Code

 

Getting Started

Download and install CMake for free from here. This is used to create the build files for the various project systems.

If you do not already have a Windows C++ compiler then you can go to Microsoft and get the free compiler Visual C++ 2010 Express edition from here.

Download and install Bison for Windows for free. You will need to select the link “Complete package, excluding sources” which comes with the installer for Bison. You will need to make sure you modify your path to be able to execute it in windows. You will need to make sure there are no spaces in the path where you decide to install Bison. Here is an example of the path I have chosen to install Bison. To use Visual C++ Express prior to 2008 Edition you will also need to install the Latest Windows Platform SDK.

C:\GnuWin32

You then need to download the MariaDB source tarballs from here. You will be downloading a snapshot of the code. The reason I am using this link rather than pointing to Launchpad is because it is the simplest way to get a copy of the code which is most convenient to most people and frees you from the hustle of installing additional tools to access the repositories.

Building MariaDB

Make you way to the root of the source directory and type the following command:

win\configure <options>

Options include (starting with enabling storage engines):

  • WITH_INNOBASE_STORAGE_ENGINE
  • WITH_PARTITION_STORAGE_ENGINE
  • WITH_ARCHIVE_STORAGE_ENGINE
  • WITH_BLACKHOLE_STORAGE_ENGINE
  • WITH_EXAMPLE_STORAGE_ENGINE
  • WITH_FEDERATED_STORAGE_ENGINE
  • __NT__ (Enable named pipe support)
  • MYSQL_SERVER_SUFFIX=<suffix> ( Server suffix, default none)
  • COMPILATION_COMMENT=<comment>  (Server comment, default “Source distribution”)
  • MYSQL_TCP_PORT=<port>   (Server port, default 3306 if you have an existing installation of MySQL you might ant to change the port to something like 3307)
  • CYBOZU (Default character set is UTF8)
  • EMBED_MANIFESTS (Embed custom manifests into final exes, otherwise VS  default will be used. (Note – This option should only be used by MySQL AB.))
  • WITH_EMBEDDED_SERVER (Configure solution to produce libmysqld.dll and the static mysqlserver.lib)

So this is what the command line would look like…

win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro WITH_EMBEDDED_SERVER

Next you need to execute one of the batch files to projece the project files for your C++ compiler. So for Visual Studio 8 (or Visual C++ 2005 express edition) , do…

win\build-vs8

For Visual Studio 7.1, do…

win\build-vs71

MariaDB does not support building with nmake so for now within the root of your source directory, if building with Visual C++ then you should see the file mysql.sln. Execute the file to launch Visual C++ IDE and from within the IDE project menu, run the build solution command.

Once you have built your solution, you will find that the compiled MariaDB files reside in the same folders as the MariaDB source files. So to get them out and install them into a separate folder, here is what you need to do.

Create the directories where you want to install MariaDB. For example, to install into C:\mysql, use these commands:

C:\> mkdir C:\mysql
C:\> mkdir C:\mysql\bin
C:\> mkdir C:\mysql\data
C:\> mkdir C:\mysql\share
C:\> mkdir C:\mysql\scripts

If you want to compile other clients and link them to MariaDB, you should also create several additional directories:

C:\> mkdir C:\mysql\include
C:\> mkdir C:\mysql\lib
C:\> mkdir C:\mysql\lib\debug
C:\> mkdir C:\mysql\lib\opt

If you want to benchmark MariaDB, which requires perl support, create this directory:

C:\> mkdir C:\mysql\sql-bench

From the working directory, copy into the C:\mysql directory the following files and directories:

C:\> cd \workdir
C:\workdir> mkdir C:\mysql
C:\workdir> mkdir C:\mysql\bin
C:\workdir> copy client\Release\*.exe C:\mysql\bin
C:\workdir> copy sql\Release\mysqld.exe C:\mysql\bin\mysqld.exe
C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
C:\workdir> xcopy share\*.* C:\mysql\share /E

If you want to compile other clients and link them to MariaDB, you should also copy several libraries and header files:

C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\debug
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\debug
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\debug
C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\opt
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\opt
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\opt
C:\workdir> copy include\*.h C:\mysql\include
C:\workdir> copy libmysql\libmysql.def C:\mysql\include

If you chose another build configuration other than “Release” for example “Debug” then you need to make the appropriate changes in the paths above.

If you want to benchmark MariaDB, you should also do this:

C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E

In a later tutorial I will show you how to manually set up the MariaDB server to run both manually or as a Windows Service so as to get to be able to use it.

 

 

2 Responses to “How to Build and Install MariaDB From Source on Windows”

  1. Wlad says:

    Are you still on MariaDB5.1? (asking because your instructions are overly complicated and would not apply to any of following versions)

    I would warmly recommend jumping directly to 5.3 or 5.5(alpha to be released tioday), especially on Windows.

    As for “how to build” there are detailled instructions in the knowlegde base
    as well as articles on creating and updgrading services (via mysql_install_db.exe)

    • sobbayi says:

      Thanks Wlad, this was in a direct response to a question on MariaDB 5.1. I will soon be doing a simplified update/new write-up for the most current version in a bout 3 weeks time :) . I will actually get some hands on MariaDB 5.5 this weekend

Leave a Reply

    © 2003, 2012 Sobbayi Tech

Home Sobbayi.com

Switch to our mobile site