MariaDBのインストール

提供: とある社畜の頭脳整理
2019年9月13日 (金) 16:49時点におけるRin-scrooge (トーク | 投稿記録)による版 (→‎設定)
ナビゲーションに移動 検索に移動

さくらの連絡サーバー上でコーディングするの大変なので、VirtualBox上に環境作成をはじめました。
一応、OSはArchLinuxなので備忘録的にこちらに上げておきます。
(参考になれば幸いです…)

MariaDBって?

私もはじめは「なんじゃこりゃ?」って思っていました。
同じく「なんじゃこりゃ?」って思った方はこちらをご覧になると、「なるほど!」ってなるかと思います。
MariaDB - Wikipedia


インストール

基本的にはArchWikiに従ってインストールしていきます。

下記コマンドを実行して、MariaDBをインストールします。

pacman -S mariadb


インストールしたら以下のコマンドをそのまま実行します。

mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

何をしているかと言うと…こんなことをしているようです。


そしたら、MariaDBのサービスを以下のコマンドで有効化します。

systemctl start mariadb
systemctl enable mariadb

設定

引き続き以下のコマンドを実行して、設定していきます。

mysql_secure_installation

色々とメッセージが出てきますが以下のような内容です。
特にこだわりが無いのであれば、[Y/n]は「Y」で問題ありません。

「NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!」
「注:このスクリプトのすべての部分を実行することは、本番使用中のすべてのMariaDBサーバーに推奨されます! 各ステップを注意深く読んでください!」

「In order to log into MariaDB to secure it, we'll need the current password for the root user.」
「MariaDBにログインしてセキュリティを確保するには、rootユーザーの現在のパスワードが必要です。」

「If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here.」
「MariaDBをインストールしたばかりで、まだrootパスワードを設定していない場合は、ここでEnterキーを押すだけです。」

はい…指示に従ってEnterキーを押します。

「OK, successfully used password, moving on...」
「OK、パスワードを正常に使用しました。次に進みます...」

次に進みます…

「Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation.」
「rootパスワードを設定するか、unix_socketを使用すると、適切な承認なしに誰もMariaDB rootユーザーにログインできなくなります。」

「You already have your root account protected, so you can safely answer 'n'.」
「ルートアカウントは既に保護されているため、「n」と安全に答えることができます。」

「Switch to unix_socket authentication [Y/n] 」
「unix_socket認証に切り替えます[Y / n]」

切り替えたいので「Y」で答えます…

「Enabled successfully!」
「有効になりました!」

「Reloading privilege tables..」
「特権テーブルの再読み込み..」

「 ... Success!」
「... 成功!」

次に進みます…

「You already have your root account protected, so you can safely answer 'n'.」
「ルートアカウントは既に保護されているため、「n」と安全に答えることができます。」

「Change the root password? [Y/n] 」
「ルートパスワードを変更しますか? [Y / n]」

変更したいので「Y」で答えます…

New password: 
Re-enter new password:

rootのパスワードを2回入力します。

「Password updated successfully!」
「パスワードが正常に更新されました!」

「Reloading privilege tables..」
「特権テーブルの再読み込み..」

 「... Success!」
「... 成功!」

次に進みます…

「By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.」
「デフォルトでは、MariaDBインストールには匿名ユーザーが含まれており、ユーザーアカウントを作成しなくても誰でもMariaDBにログインできます。」

「This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.」
「これはテストのみを目的としており、インストールを少しスムーズにするためのものです。実稼働環境に移行する前にそれらを削除する必要があります。」

「Remove anonymous users? [Y/n]」
「匿名ユーザーを削除しますか? [Y / n]」

当然削除なので「Y」で答えます。

「 ... Success!」
「 ... 成功!」

次…

「Normally, root should only be allowed to connect from 'localhost'. 」
「通常、ルートは「localhost」からの接続のみを許可する必要があります。」

「This ensures that someone cannot guess at the root password from the network.」
「これにより、誰かがネットワークからルートパスワードを推測できないようになります。」

「Disallow root login remotely? [Y/n] 」
「リモートでrootログインを許可しませんか? [Y / n]」

rootはローカルのみにしたいので「Y」で答えます。

「 ... Success!」
「 ... 成功!」

次…

「By default, MariaDB comes with a database named 'test' that anyone can access.」
「デフォルトでは、MariaDBには「test」という名前のデータベースが付属しており、誰でもアクセスできます。」

「This is also intended only for testing, and should be removed before moving into a production environment.」
「これもテスト専用であり、本番環境に移行する前に削除する必要があります。」

「Remove test database and access to it? [Y/n] 」
「テストデータベースを削除してアクセスしますか? [Y / n]」

余計なものは消したいので「Y」で答えます…

「 - Dropping test database...」
「-テストデータベースを削除しています...」

「 ... Success!」
「 ... 成功!」

「 - Removing privileges on test database...」
「 -テストデータベースの権限を削除しています...」

「 ... Success!」
「 ... 成功!」

つぎ…

「Reloading the privilege tables will ensure that all changes made so far will take effect immediately.」
「特権テーブルをリロードすると、これまでに行われたすべての変更がすぐに有効になります。」

「Reload privilege tables now? [Y/n] 」
「今すぐ特権テーブルをリロードしますか? [Y / n]」

すぐに反映したいので「Y」です…

「 ... Success!」
「 ... 成功!」

「Cleaning up...」
「クリーニングアップ…」

「All done!」
「すべて実行した!」

「If you've completed all of the above steps, your MariaDB installation should now be secure.」
「上記の手順をすべて完了したら、MariaDBのインストールは安全になります。」

「Thanks for using MariaDB!」
「MariaDBをご利用いただきありがとうございます!」

設定完了!

ユーザーの追加