MariaDB

概要

MariaDB サーバーのインストールと設定

ユーザー/グループの作成

[root]# useradd -s /sbin/nologin --no-create-home --user-group mysql

インストール

    # AL 9.x
    [root]# dnf install cmake ncurses ncurses-devel
    # Ubuntu 24.04
    [root]# apt install cmake libncurses-dev librocksdb-dev

    [root]# tar xvfz mariadb-13.0.2.tar.gz
    [root]# cd mariadb-x.x.x
    [root]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
                  -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
                  -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=ON
                  -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=ON

    cmake を再度行う場合は、CMakeCache.txt を削除して、[root]# make clean

    [root]# make -j3

    [  0%] Performing download step (download, verify and extract) for 'libfmt'
    -- verifying file...
       ファイルを検証中...
       file='/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip'
    -- MD5 hash of
       /path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip
       does not match expected value
       MD5ハッシュの不一致
       expected: '6083253772ad29e73a4d5920be08918e'
         期待値:
         actual: 'd41d8cd98f00b204e9800998ecf8427e'
         実際値:
    -- File already exists but hash mismatch. Removing...
       ファイルは存在するが、ハッシュが一致しない。削除...
    -- Downloading...
       ダウンロード中...
       dst='/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip'
       timeout='none'
       inactivity timeout='none'
    -- Using src='https://github.com/fmtlib/fmt/releases/download/12.2.0/fmt-12.2.0.zip'
    -- Retrying...
       再試行中...
    -- Using src='https://github.com/fmtlib/fmt/releases/download/12.2.0/fmt-12.2.0.zip'
    -- Retry after 5 seconds (attempt #2) ...
       5秒後に再試行(2回目の試行)...
    -- Using src='https://github.com/fmtlib/fmt/releases/download/12.2.0/fmt-12.2.0.zip'

    ● 何度繰り返しても、fmt がダウンロードできない場合

      手動で、https://github.com/fmtlib/fmt/releases/download/12.2.0/fmt-12.2.0.zip
     をダウンロード、/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip へ配置

    [root]# make -j3

    [  0%] Performing download step (download, verify and extract) for 'libfmt'
    -- verifying file...
       ファイルを検証中...
       file='/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip'
    -- File already exists and hash match (skip download):
       ファイルは既に存在し、ハッシュも一致(ダウンロードをスキップ):
       file='/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip'
       MD5='6083253772ad29e73a4d5920be08918e'
    -- extracting...
       展開中...
       src='/path/to/mariadb-xx.x.x/extra/libfmt/src/fmt-12.2.0.zip'
       dst='/path/to/mariadb-xx.x.x/extra/libfmt/src/libfmt'

    [root]# make -j3 test
    [root]# make -j3 install
    [root]# /usr/local/mysql/bin/mariadb -V   # バージョン確認
    [root]# cd ..
    [root]# rm -vrf mariadb-x.x.x

    ※ バージョンアップ時には、インストールして再起動

環境設定

MariaDB を利用する全てのユーザーにて、以下を実行

[user]$ vim ~/.bash_profile

[user]$ vim ~/.profile(Ubuntu: ~/.bash_profile, ~/.bash_login が無い場合)

    PATH=${PATH}:/usr/local/mysql/bin

[user]$ . ~/.bash_profile

共有ライブラリ読み込み

[root]# updatedb

[root]# locate libmariadb

    /usr/local/mysql/lib/libmariadb.so
    /usr/local/mysql/lib/libmariadb.so.3

[root]# vim /etc/ld.so.conf.d/mysql.conf

    /usr/local/mysql/lib
・/etc/ld.so.cache を更新

[root]# ldconfig -v

    -v : 進捗状況
・確認

[root]# ldconfig -p | grep libmariadb

    -p : /etc/ld.so.cache の内容確認

    libmariadb.so.3 => /usr/local/mysql/lib/libmariadb.so.3
    libmariadb.so => /usr/local/mysql/lib/libmariadb.so