CleanUp

備忘録と豆の知識

備忘録 CentOS7にMariaDB最新版をインストール/初期設定

最新版MariaDBをインストールする。

アーキテクチャを確認する。自分のはx86_64だった。

$ arch

repository configuration toolを参照して、自分のアーキテクチャに対応するバージョンを見つける。
https://downloads.mariadb.org/mariadb/repositories

/etc/yum.repos.d/ 内にMariaDB.repoファイルを作成し、リポジトリの情報を記述する。

$ sudo vi /etc/yum.repos.d/MariaDB.repo


//次を記述

# MariaDB 10.2 CentOS repository list - created 2018-05-13 07:23 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

次のコマンドでインストールを開始する。

$ sudo yum install MariaDB-server MariaDB-client

// 確認
$ sudo rpm -qa | grep MariaDB

次のコマンドで自動起動

$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb | grep enabled

文字コードをセット。

$ vi /etc/my.cnf


// 次を記述

character-set-server=utf8

MariaDBを起動する。

$ sudo systemctl start mariadb


対話的に設定する、mysql_secure_installationを実行する。

$ mysql_secure_installation

// 何も入力せずEnter
Enter current password for root (enter for none): 

// MySQL rootパスワードを設定する
Set root password? [Y/n] Y
// パスワードを2度入力
New password: 
Re-enter new password: 

// 匿名ユーザーを削除
Remove anonymous users? [Y/n] Y

// リモートからのrootログインを禁止
Disallow root login remotely? [Y/n] Y

// testデータベースはいらない
Remove test database and access to it? [Y/n] Y

// 設定を適用させるため、権限テーブルを今すぐ再読み込み
Reload privilege tables now? [Y/n] Y

rootでログインする。

$ mysql -u root -p

// 先ほど設定したrootパスワードを入力
Enter password:


MariaDB [(none)]> 


これで最新版のMariaDBをインストールし、初期設定まで完了しました。