Skip to content

Building MySQL 8.x

linuxonz edited this page Oct 24, 2024 · 45 revisions

Building MySQL 8.x

Below versions of MySQL are available in respective distributions at the time creation of these build instructions:

  • RHEL (8.8, 8.10) have 8.0.36
  • RHEL (9.2, 9.4) have 8.0.36
  • Ubuntu 22.04, 24.04 has 8.0.39

The instructions provided below specify the steps to build MySQL version 8.4.3 on Linux on IBM Z for the following distributions:

  • RHEL (8.8, 8.10, 9.2, 9.4)
  • SLES (15 SP5, 15 SP6)
  • Ubuntu (22.04, 24.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

1. Build using script

If you want to build MySQL using manual steps, go to Step 2. Use the following commands to build MySQL using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MySQL/8.4.3/build_mysql.sh

# Build MySQL
bash build_mysql.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 4. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2. Install dependencies

export SOURCE_ROOT=/<source_root>/
export PATCH_URL=https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MySQL/8.4.3/patch

2.1. Install required dependencies

  • RHEL (8.8, 8.10)
    sudo yum install -y curl wget bison bzip2 gcc gcc-c++ git hostname ncurses-devel openssl openssl-devel pkgconfig tar procps wget zlib-devel doxygen cmake diffutils rpcgen make libtirpc-devel libarchive net-tools gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-plugin-gcc cpan perl-JSON perl-Memoize psmisc zip mecab-ipadic
    sudo PERL_MM_USE_DEFAULT=1 cpan Expect
    source /opt/rh/gcc-toolset-12/enable
  • RHEL (9.2, 9.4)
    sudo yum install -y --allowerasing curl
    sudo yum install -y wget bison bzip2 bzip2-devel gcc gcc-c++ git xz xz-devel hostname ncurses ncurses-devel openssl procps openssl-devel pkgconfig tar wget zlib-devel doxygen cmake diffutils rpcgen make libtirpc-devel libarchive tk-devel gdb gdbm-devel sqlite-devel readline-devel libdb-devel libffi-devel libuuid-devel libnsl2-devel net-tools gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-plugin-gcc cpan perl-JSON perl-Memoize psmisc zip mecab-ipadic
    sudo PERL_MM_USE_DEFAULT=1 cpan Expect
    source /opt/rh/gcc-toolset-12/enable
  • SLES (15 SP5, 15 SP6)
    sudo zypper install -y curl make cmake bison gcc13 gcc13-c++ git-core hostname ncurses-devel openssl procps openssl-devel pkg-config gawk doxygen libtirpc-devel rpcgen tar wget net-tools-deprecated xz timezone gzip unzip perl-JSON perl-Expect
    sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-13 13
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
    sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-13 13
    sudo ln -sf /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc
    sudo ln -sf /usr/bin/cpp-13 /usr/bin/cpp
  • Ubuntu 22.04
    sudo apt-get update
    sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl dpkg-dev wget tar bison cmake gcc g++ git hostname libncurses-dev libssl-dev make openssl pkg-config gawk procps doxygen python-is-python3 python2 net-tools libtirpc-dev libarchive-tools xz-utils libjson-perl libexpect-perl mecab-ipadic-utf8 psmisc zip
    sudo apt-get install -y libprotoc-dev libprotobuf-c-dev libprotobuf-dev protobuf-c-compiler protobuf-compiler
  • Ubuntu 24.04
    sudo apt-get update
    sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl dpkg-dev wget tar bison cmake gcc g++ git hostname libncurses-dev libssl-dev make openssl pkg-config gawk procps doxygen python-is-python3 net-tools libtirpc-dev libarchive-tools xz-utils libjson-perl libexpect-perl mecab-ipadic-utf8 psmisc zip zlib1g-dev
    sudo apt-get install -y libprotoc-dev libprotobuf-c-dev libprotobuf-dev protobuf-c-compiler protobuf-compiler

3. Build, install and test

3.1. Download MySQL source code

cd $SOURCE_ROOT
git clone -b mysql-8.4.3 --depth 1 https://github.com/mysql/mysql-server.git
cd mysql-server
curl -sSL "${PATCH_URL}/mt-asm.patch" | git apply -
curl -sSL "${PATCH_URL}/NdbHW.patch" | git apply -
curl -sSL "${PATCH_URL}/router-test.patch" | git apply -
curl -sSL "${PATCH_URL}/ut0rnd.patch" | git apply -
mkdir build
cd build

3.2. Configure, Build and Install MySQL

# For RHEL 8.x, 9.x, SLES 15 Only
cmake .. -DWITH_SSL=system

# For Ubuntu Only
cmake .. -DWITH_SSL=system -DWITH_PROTOBUF=system

# For all distros
make -j $(nproc)
sudo make install

Note: For more MySQL source configuration options, please visit their official guide.

3.3. Run unit tests (Optional)

  • Use the below commands to run the unit test suite:
    cd $SOURCE_ROOT/mysql-server/build
    
    # For RHEL 8.x, 9.x, SLES 15 Only
    export LD_PRELOAD=$SOURCE_ROOT/mysql-server/build/library_output_directory/libprotobuf-lite.so.24.4.0:$LD_PRELOAD   # To fix routertest test failures
    
    # For all distros
    make test
  • Use the below command to run an individual test case (for example routertest_component_routing_splicer):
    ctest -VV -R routertest_component_routing_splicer

3.4. Run integration tests (Optional)

  • Use the below commands to run the integration test suite:
    # Temporarily change permissions of install dirs that tests write to.
    sudo chmod -f 777 /usr/local/mysql/bin /usr/local/mysql/lib/plugin
    mkdir -p $SOURCE_ROOT/mysql-test/var/tmp
    cd /usr/local/mysql/mysql-test/
    # Skip the main.file_contents test because the docs dir path hardcoded in the test is broken when mysql is installed under /usr
    ./mysql-test-run.pl --vardir=${SOURCE_ROOT}/mysql-test/var --tmpdir=${SOURCE_ROOT}/mysql-test/var/tmp --suite=main --force --skip-test=file_contents
    sudo chmod -f 755 /usr/local/mysql/bin /usr/local/mysql/lib/plugin
  • Use the below commands to run an individual test case (for example main.slow_log):
    sudo chmod -f 777 /usr/local/mysql/bin /usr/local/mysql/lib/plugin
    ./mysql-test-run.pl --vardir=${SOURCE_ROOT}/mysql-test/var --tmpdir=${SOURCE_ROOT}/mysql-test/var/tmp --suite=main main.slow_log
    sudo chmod -f 755 /usr/local/mysql/bin /usr/local/mysql/lib/plugin

Notes:

  • Below test cases might fail if IPv6 is not enabled:
    • NdbGetInAddr-t
    • routertest_harness_net_ts_internet
    • routertest_component_http_server

4. Post installation setup and testing (Optional)

Refer to this guide for the Postinstallation Setup and Testing overview.

References:

Clone this wiki locally