User Tools

Site Tools


servers:linux:mariadb

Information

Prerequisites

Resources

Settings

  • Settings being done before installation is intentional
sudo mkdir -p '/etc/my.cnf.d' && sudo -e '/etc/my.cnf.d/custom.cnf'
[client]
default-character-set = 'utf8mb4'

[mariadb-client]
default-character-set = 'utf8mb4'

[mariadbd]
character-set-client-handshake = 'FALSE'
character-set-server = 'utf8mb4'
collation-server = 'utf8mb4_unicode_ci'
init-connect='SET NAMES utf8mb4'
expire_logs_days = '7'
max_binlog_size = '100M'
skip-networking = 'On'
table_definition_cache = '1400'

Verify

sudo mariadb-admin variables | egrep 'utf8|networking|socket'

Dependencies

sudo dnf install 'mariadb-server'

Initial Setup

sudo systemctl enable 'mariadb' --now && sudo mariadb-secure-installation

Database Repair and Optimization

One-shot

sudo mariadb-check --optimize --all-databases --force --extended --auto-repair

Create MySQL User

sudo mariadb
CREATE USER 'maintenance'@'localhost' IDENTIFIED BY 'x';
GRANT SELECT, INSERT ON *.* to 'maintenance'@'localhost';
FLUSH PRIVILEGES;
EXIT

Authentication File

sudo mkdir -p '/var/lib/mysql/auth' && sudo -e '/var/lib/mysql/auth/maintenance' && sudo chown -v -R 'mysql':'mysql' '/var/lib/mysql/auth' && sudo chmod -v '600' '/var/lib/mysql/auth/maintenance' && sync
[mariadb-check]
user=maintenance
password=x

Service

sudo -e '/etc/systemd/system/db-m.service'
[Service]
User=mysql
Group=mysql
Type=oneshot
ExecStart='/usr/bin/mariadb-check' --defaults-extra-file='/var/lib/mysql/auth/maintenance' --optimize --all-databases --force --extended --auto-repair
ExecStartPost='/usr/bin/sync'

Timer

sudo -e '/etc/systemd/system/db-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'db-m.timer' --now && sudo systemctl start 'db-m' && sudo systemctl status 'db-m' -l
[Unit]
Description=MariaDB Database Check, Repair, and Optimization
After=mariadb.service

[Timer]
OnCalendar=weekly
Persistent=true

[Install]
WantedBy=timers.target

Notable Commands

Show Users on Server

select User,Host from mysql.user;

Socket File

/var/lib/mysql/mysql.sock
2)
for localhost game servers
/usr/local/www/wiki/data/pages/servers/linux/mariadb.txt · Last modified: by Sean Rhone