LoginSignup
20
22

More than 3 years have passed since last update.

EC2(Amazon Linux 2)にmariaDBを導入する

Last updated at Posted at 2019-07-22

今回の目的

先輩から教えてもらったサーバー構築の備忘録、物理サーバーでやったことをAWSで確認中。
mariadbをインストールし,EC2内でログインする。前回下の原因でできなかったDBをインストールします。

注意事項

Amazon Linux 2のインスタンスを使用すること。Amazon Linuxだとmariadbがサポートされていません!

インストール

# インストール
$ sudo yum install -y mariadb-server

# 起動
$ sudo systemctl start mariadb

# 有効化
$ sudo systemctl enable mariadb
$ sudo systemctl is-enabled mariadb

# セキュリティ設定 rootのパスワード等を設定します。全部Yでもいいかなと思っています。
$ sudo mysql_secure_installation
Set root password? [Y/n]
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n]
 ...
Thanks for using MariaDB!


ログインしてみよう

#ルートユーザーでログイン、パスワード付きで
mysql -u root  -p

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 23
Server version: 10.3.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#ログアウト
MariaDB [(none)]> exit
Bye

これでmariadbがEC2内で使えるようになりました。大規模でなければRDSでなくてもいいと思います。
次はSSL認証をやっていこうと思います。それでは!

参考文献

Amazon Linux 2でサーバ作成 (Apache2.4+PHP7.2+MariaDB)

20
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
22