インストール手順をまとめます。
MariaDBのアンインストール
CentOS7.1はMariaDBがインストールされています。
MySQLとは競合するのでアンイスールしておきます。
shell> sudo yum remove -y mariadb-libs
yumリポジトリ
MySQLが提供するパッケージを使用してyumリポジトリをインストールします。
shell> sudo yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
MySQLのインストール
MySQLをインストールします。
shell> sudo yum install -y mysql-community-server
起動確認
MySQLを起動します。
shell> sudo service mysqld start
ステータスを確認します。"running"と出ていれば正常に起動できています。
shell> sudo service mysqld status
パスワード確認
仮設定されたパスワードがインストール時にログファイルに出力されています。
以下のコマンドで確認します。
shell> sudo cat /var/log/mysqld.log | grep "temporary password"
セキュリティ設定
以下のコマンドでセキュリティ関連の設定を開始します。
shell> mysql_secure_installation
rootユーザのパスワード設定
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
... skipping.
初期パスワードを入力します。
有効期限が切れているため、新しいパスワードを求められます。
新しいパスワードを設定します。
設定後、パスワード強度が表示され、変更するか聞かれます。
問題なければ"n"を入力します。
anonymousユーザの削除
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. 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? (Press y|Y for Yes, any other key for No) : y
Success.
anonymousを削除するか聞かれます。
匿名ユーザのログインを防ぐために削除しましょう。
削除する場合は"y"を入力します。
rootユーザによるリモートログイン
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
rootユーザによるリモートログインを無効にするか聞かれます。
無効にする場合は"y"を入力します。
testデータベースの削除
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
インストール時に作成されているtestデータベースを削除するか聞かれます。
削除する場合は"y"を入力します。
権限テーブルのリロード
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
ユーザ権限のテーブルをリロードするかを聞かれます。
"y"を入力します。
自動起動設定
chkconfigで自動起動設定を行います。
shell> sudo chkconfig mysqld on
接続確認
MySQLに接続してみます。
shell> mysql -u root -p
パスワード入力後、mysqlのプロンプトが表示されれば成功です。