備忘録

備忘録

LinuxにMariaDBをインストールする方法

Ⅰ. はじめに

タイトルの通り「LinuxにMariaDBをインストールする方法」です。

Ⅱ. やり方

1. 以下コマンドを実行する
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup \
  | sudo bash -s -- --mariadb-server-version="mariadb-10.6"
2. MariaDB をインストールする
apt -y install mariadb-server mariadb-client
# yum -y install mariadb-server mariadb-client
3. MariaDBを起動する
systemctl enable mariadb
systemctl start mariadb
4. 初期設定を行う
mysql_secure_installation
(画面の指示に従う)
5. その他パラメータの設定

※このパラメータは適当なので環境に合わせて設定すること

# Ubuntu
vim /etc/mysql/mariadb.conf.d/50-server.cnf

# CentOS
# vim /etc/my.cnf.d/server.cnf

[server]
default-time-zone=+09:00

[mysqld]
#innodb_buffer_pool_size=16G
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci

max_connections = 10000
max_user_connections = 10000
max_connect_errors = 9999999
query_cache_type = 2 # 0=off, 1=on, 2=demand
query_cache_size = 512M
query_cache_limit = 128M
thread_cache_size = 1000
wait_timeout = 60
event_scheduler = ON
#datadir=/data/mysql
#socket=/data/mysql/mysql.sock
vim /etc/my.cnf.d/client.cnf
[client]
# socket=/data/mysql/mysql.sock
5. MariaDBを再起動する
systemctl restart mariadb

以上

その他設定