Building MySQL from Source  /  Installing MySQL from Source

Chapter 1 Installing MySQL from Source

Building MySQL from the source code enables you to customize build parameters, compiler optimizations, and installation location. For a list of systems on which MySQL is known to run, see

Before you proceed with an installation from source, check whether we produce a precompiled binary distribution for your platform and whether it works for you. We put a great deal of effort into ensuring that our binaries are built with the best possible options for optimal performance. Instructions for installing binary distributions are available in Installing MySQL on Unix/Linux Using Generic Binaries.

To obtain a source distribution for MySQL, see How to Get MySQL. MySQL source distributions are available as compressed tar files, Zip archives, or RPM packages. Distribution files have names of the form mysql-VERSION.tar.gz,, or mysql-VERSION.rpm, where VERSION is a number like 5.0.96.

To perform a MySQL installation using the source code:

To install MySQL from source, the following system requirements must be satisfied:

  • GNU gunzip to uncompress the distribution and a reasonable tar to unpack it (if you use a .tar.gz distribution), or WinZip or another tool that can read .zip files (if you use a .zip distribution).

    GNU tar is known to work. The standard tar provided with some operating systems is not able to unpack the long file names in the MySQL distribution. You should download and install GNU tar, or if available, use a preinstalled version of GNU tar. Usually this is available as gnutar, gtar, or as tar within a GNU or Free Software directory, such as /usr/sfw/bin or /usr/local/bin. GNU tar is available from

  • A working ANSI C++ compiler. GCC 3.4.6 or later, Sun Studio 10 or later, Visual Studio 2005 or later, and many current vendor-supplied compilers are known to work.

  • A good make program. Although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or newer. It may already be available on your system as gmake. GNU make is available from

  • libtool 1.5, available from 1.5.24 or later is recommended.

If you are using a version of gcc recent enough to understand the -fno-exceptions option, it is very important that you use this option. Otherwise, you may compile a binary that crashes randomly. Also use -felide-constructors and -fno-rtti along with -fno-exceptions. When in doubt, do the following:

CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
       -fno-exceptions -fno-rtti" ./configure \
       --prefix=/usr/local/mysql --enable-assembler \

On most systems, this gives you a fast and stable binary.

If you run into problems and need to file a bug report, please use the instructions in How to Report Bugs or Problems.

Download this Excerpt
PDF (US Ltr) - 194.2Kb
PDF (A4) - 194.9Kb
EPUB - 66.3Kb
HTML Download (TGZ) - 50.7Kb
HTML Download (Zip) - 62.7Kb
User Comments
  Posted by Chris Calender on January 18, 2012
How to Build MySQL 5.5 from Source Code on Windows
  Posted by Anoop Viswanath on July 2, 2014
Detailed instructions for compiling MySQL Server from source code on Linux.

This one worked for me.
Sign Up Login You must be logged in to post a comment.