Amazon Linux に MySQL-Server & Client をインストールする


特にCentOSやRHELとやりかたが変わるわけではありません。自分向けかんたんメモ。

インストール環境

AMI : amzn-ami-hvm-2016.03.0.x86_64-gp2 (ami-f80e0596)
環境: EC2/t2.micro

MySQL Client/Serverのインストール

console
$ sudo su -
$ yum install -y mysql yum install -y mysql-server
$ yum info mysql mysql-server
読み込んだプラグイン:priorities, update-motd, upgrade-helper
インストール済みパッケージ
名前                : mysql
アーキテクチャー    : noarch
バージョン          : 5.5
リリース            : 1.6.amzn1
容量                : 0.0
リポジトリー        : installed
提供元リポジトリー  : amzn-main
要約                : MySQL meta package
URL                 : http://www.mysql.com
ライセンス          : GPLv2 with exceptions
説明                : MySQL is a multi-user, multi-threaded SQL database server.
                    : MySQL is a client/server implementation consisting of a
                    : server daemon (mysqld) and many different client programs
                    : and libraries. The base package contains the standard
                    : MySQL client programs and generic MySQL files.

名前                : mysql-server
アーキテクチャー    : noarch
バージョン          : 5.5
リリース            : 1.6.amzn1
容量                : 0.0
リポジトリー        : installed
提供元リポジトリー  : amzn-main
要約                : The MySQL server and related files
URL                 : http://www.mysql.com
ライセンス          : GPLv2 with exceptions
説明                : MySQL is a multi-user, multi-threaded SQL database server.
                    : MySQL is a client/server implementation consisting of a
                    : server daemon (mysqld) and many different client programs
                    : and libraries. This package contains the MySQL server and
                    : some accompanying files and directories.
$ mysql --version
mysql  Ver 14.14 Distrib 5.5.46, for Linux (x86_64) using readline 5.1

サービス自動起動設定

console
$ chkconfig mysqld on
$ chkconfig | grep mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

MySQL起動

console
$ service mysqld start

rootパスワード変更

mysqlにログインし、rootのパスワードを変更します
input-your-passwordの部分は任意に変更してください。

console
$ mysql -u root
mysql> show databases;
mysql> use mysql;
mysql> show tables;
mysql> update user set password=password(‘input-your-password’) where user='root';
mysql> flush privileges;
mysql> quit;

上で設定したパスワード付きで再度ログインを試みます。
成功したらquitで抜けます。

console
$ mysql -u root -p
password:
mysql> quit;