Rate This Document
Findability
Accuracy
Completeness
Readability

Compilation and Installation

This section uses MariaDB 10.3.9 as an example. You can also refer to this section for MariaDB of other versions.

To install MariaDB by compiling the source code, perform the following steps:

  1. Go to the /root directory and download the MariaDB 10.3.9 source package.
    1
    2
    cd /root/
    wget https://archive.mariadb.org//mariadb-10.3.9/source/mariadb-10.3.9.tar.gz --no-check-certificate
    

    You can also use a browser to download the source package and upload it to the server. Download URL: https://downloads.mariadb.org/mariadb/10.3.9/

  2. Decompress the source package.
    1
    tar zxvf mariadb-10.3.9.tar.gz
    
  3. Go to the directory generated after the decompression.
    1
    cd mariadb-10.3.9
    
  4. Perform the compilation.
    1
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/data/mariadb/data -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/data/mariadb/run/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
    

    To install MariaDB 10.3.8 or MariaDB 10.3.9 on openEuler 22.03, run the following command:

    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/data/mariadb/data -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/data/mariadb/run/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DCMAKE_C_COMPILER=/opt/tools/gcc/gcc-7.3.0/bin/gcc -DCMAKE_CXX_COMPILER=/opt/tools/gcc/gcc-7.3.0/bin/g++

    Table 1 describes part of the directory parameters. Set them based on your requirements.

    Table 1 Key directories involved in compilation and installation

    Parameter

    Description

    -DCMAKE_INSTALL_PREFIX

    Software installation directory

    -DMYSQL_DATADIR

    Data file directory

    -DSYSCONFDIR

    Configuration file directory

    -DMYSQL_UNIX_ADDR

    SOCK file directory

    -DCMAKE_C_COMPILER

    Storage path for GCC installation

    If no path is specified when GCC is installed, GCC is stored in /usr/local/bin by default.

  5. Perform the installation.
    1
    make -j 96 && make install
    

    The -j 96 parameter leverages the multi-core CPUs to accelerate the compilation. The number following -j indicates the number of CPU cores. You can run the cat /proc/cpuinfo | grep processor | wc -l command to query the number of CPU cores. This value must be less than or equal to the number of CPU cores.

  6. View MariaDB installation directory.
    1
    ls /usr/local/mariadb/
    

  7. Check the database version.
    1
    /usr/local/mariadb/bin/mysqld --version