Installation and compilation from source code 1/3

Some MySQL options must be positioned during the time of compilation of the software. For exemple, the weighting system for full text search in natural langage can be adjusted, but it involves editing the file storage/myisam/ ftdefs.h. The following shows how to compile MySQL from downloaded sources from a Git repository. The procedure has been tested on the Ubuntu 14.04 LTS distribution with the 5.7.9 MySQL version.

Utilities and dependencies

Before starting the installation, it is necessary to synchronize the indexes of available packages and to upgrade packages already installed :

shell> apt-get update
shell> apt-get upgrade

It is then necessary to ensure that the utilities and libraries are present on the server, and to install them if necessary :

  • gcc
  • g++
  • git
  • make
  • cmake
  • cmake-gui
  • libncurses5-dev (Debian and derivatives) or ncurses-devel (for Red Hat and derivatives)
  • bison

On Ubuntu 14.04, the installation is done in one command line as follows :

shell> apt-get install gcc g++ cmake make cmake-gui
libncurses5-dev bison git

Source files downloading

The connection to the repository and the download of sources need to git that must be beforehand installed on the machine. The command is :

shell> git clone https ://github.com/mysql/mysql-server. git
Cloning into ‘mysql-server’…
remote : Counting objects : 1102829, done.
remote : Compressing objects : 100% (890/890), done.
remote : Total 1102829 (delta 498), reused 0 (delta 0), pack-reused 1101938
Receiving objects : 100% (1102829/1102829), 561.56 MiB | 1002.00 KiB/s, done.
Resolving deltas : 100% (911211/911211), done.
Checking connectivity… done. Checking out files : 100% (24148/24148), done.

We should now position ourselves in the mysql-server folder :

shell> cd mysql-server

The display of the various branches is available this way :

shell> git branch -r

The main branches of MySQL and MySQL Cluster are displayed this way :

shell> git branch -r
origin/5.5
origin/5.6
origin/5.7
origin/HEAD -> origin/5.7
origin/cluster-7.2
origin/cluster-7.3
origin/cluster-7.4

MySQL 5.7 is already the default branch, which is confirmed by the asterisk displayed by the following command :

shell> git branch
* 5.7

If it’s not the case, then we should use the checkout option like this :

shell> git checkout 5.7

The git pull command allows us to get the last updates, if necessary :

shell> git pull
Already up-to-date.

Group and User creation

For a MySQL installation from its source code, it is necessary to create the mysql group :

shell> groupadd mysql

Then the involved user :

shell> useradd -r -g mysql mysql

Build files generation

The reference documentation advises the user to generate build files with only the root folder (here the current directory) as parameter :

shell> cmake .

This command does not work on Ubuntu 14.04 with MySQL 5.7.9. If the cmake command has to be launch again, use the « make clean » command first to delete any parasite file from a previous compilation attempt.

In the way it is, the previous command fails on Ubuntu 14.04, the system on which the installation is tested :

[…]
— MySQL currently requires boost_1_58_0
CMake Error at cmake/boost.cmake :76 (MESSAGE) :
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_ BOOST=<directory>
This CMake script will look for boost in . If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy :
export http_proxy=http ://example.com :80
Call Stack (most recent call first) :
cmake/boost.cmake :228 (COULD_NOT_FIND_BOOST)
CMakeLists.txt :429 (INCLUDE)
[…]

The alternative is to reflate the command requesting the boost download with the -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost -DENABLE_DOWNLOADS=1 options. Moreover, another error comes up later when sending make :

[…] In file included from /home/creboul/mysql-server/include/ lf.h :20 :0,
from /home/creboul/mysql-server/mysys/lf_ alloc-pin.c :98 :
/home/creboul/mysql-server/include/my_atomic.h :62 :4 : error : #error Native atomics support not found!
[…]

make[2] : *** [mysys/CMakeFiles/mysys.dir/lf_allocpin.c.o] Error 1
make[1] : *** [mysys/CMakeFiles/mysys.dir/all] Error 2
make : *** [all] Error 2

This error can be avoided by adding the -DHAVE_GCC_ATOMIC_BUILTINS=1 option, which finally gives the following command :

shell> cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost -DENABLE_DOWNLOADS=1 -DHAVE_GCC_ATOMIC_BUILTINS=1

The path in the -DWITH_BOOST option parameter indicates where the boost must be downloaded. The operation ends with the following message :

— Configuring done
— Generating done
— Build files have been written to : /home/mylogin/mysqlserver