2012年8月12日日曜日

[MySQL]インストール後に最初に行うこと

■概要 公開サービスでのMySQL利用を想定している場合、MySQLのインストール後のセキュリティ設定は不適切です。 セキュリティを強化するための設定は、個別に行うことも可能ですが、「mysql_secure_installation」コマンドを利用すると、より簡便に設定可能です。

 ■mysql_secure_installationの実行 

mysql_secure_installationを実行すると以下の設定変更が可能です。

  1. rootパスワードの設定 
  2. rootユーザによるリモートアクセスの禁止 
  3. 匿名(anonymous)ユーザの削除 
  4. デフォルトで作成されているtestデータベースの削除
bash-3.2$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] Y ->初期パスワードなし
New password:         ->rootパスワードを変更するため[Y]を入力
Re-enter new password:     ->rootパスワードを変更するため[Y]を再入力
Password updated successfully!
Reloading privilege tables..
 ... Success!
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? [Y/n] Y ->匿名ユーザを削除するため[Y]を入力
 ... Success!
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? [Y/n] Y ->rootユーザのリモートアクセスを禁止するため[Y]を入力
 ... Success!
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? [Y/n] Y ->testデータベースを削除するため[Y]を入力
 - Dropping test database...
ERROR 1010 (HY000) at line 1: Error dropping database (can't rmdir './test/', errno: 17)
 ... Failed!  Not critical, keep moving...
 - 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 ->新しい設定を即時反映するため[Y]を入力
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!



以上です。