目次

18 CentOS7 MariaDB

インストール

# yum install mariadb mariadb-server

起動

# systemctl enable mariadb.service
# systemctl start mariadb.service

初期設定

# mysql_secure_installation

設定追加

# cat /etc/my.cnf
[mysqld]
character-set-server=utf8
max_allowed_packet = 32M

ディレクトリ変更する場合

エラー

Feb  6 17:38:56 hoge sh: 2020-02-06 17:38:56 0 [Warning] Can't create test file /home/mysql/hoge .lower-test
Feb  6 17:38:56 hoge sh: #007/usr/sbin/mysqld: Can't change dir to '/home/mysql/' (Errcode: 2 "No such file or directory")
Feb  6 17:38:56 hoge sh: 2020-02-06 17:38:56 0 [ERROR] Aborting'

対応

vi /usr/lib/systemd/system/mariadb.service

ProtectSystem=full
↓↓↓
ProtectSystem=off

ProtectHome=true
↓↓↓
ProtectHome=false

PrivateDevices=false
↓↓↓
PrivateDevices=true
sed -i 's/^ProtectSystem=full/ProtectSystem=off/g' /usr/lib/systemd/system/mariadb.service
sed -i 's/^ProtectHome=true/ProtectHome=false/g' /usr/lib/systemd/system/mariadb.service
sed -i 's/^PrivateDevices=false/PrivateDevices=true/g' /usr/lib/systemd/system/mariadb.service
grep '^PrivateDevices\|^ProtectHome\|^ProtectSystem' /usr/lib/systemd/system/mariadb.service
PrivateDevices=true
ProtectSystem=off
ProtectHome=false

起動スクリプトのタイムアウト値

Timeout追加

/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf

[Service]
TimeoutStartSec=3600

systemd リロード

systemctl daemon-reload

確認

# systemctl show mariadb -p TimeoutStartUSec
TimeoutStartUSec=1h