AWS EC2のサーバーにMySQLをインストール

前回の続きです。前回と同様に詳しいインストール方法はこちらに書いています。ここでは掻い摘んで説明します。

今回はMySQLデータベースをインストールします。

$sudo yum install mysql-server
$sudo service mysqld start
$sudo chkconfig mysqld on

MySQL rootのパスワードを変更

こちらの「MySQL サーバーをセキュリティで保護するには」を参考に進めて下さい。AWSはこの処理の実行を推奨しています。

当初、私はこのチュートリアルの存在に気付かず、手動で変更しました。やり方を以下に記しておきます。しかし、繰り返しになりますが、こちらを行う方がセキュリティの観点から望ましいですし、楽です。

$mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2265
Server version: 5.5.46 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql>

rootのパスワードを変更します。設定したパスワードは決して忘れないようにして下さい。

mysql> update mysql.user set password=password(<rootのパスワード>) where user = 'root';
mysql> flush privileges;
mysql> exit;

1行目でパスワードの変更を行います。

2行目は変更を即座に反映させる為のコマンドです。

3行目でMySQLからログアウトします。

変更したパスワードでログインしてみましょう。

$mysql -u root -p
Enter password:

パスワードを訪ねてくるので、先ほど設定したパスワードを入力します。

MySQLデータベースのインストールは以上です。

次回はPHPのインストールに関して書きます。