初期設定

環境

本ページは以下の環境で実施しています。

初期設定

MySQLをインストールしたら、まず設定しておきたい項目をまとめておきます。

インストール手順は以下を参照してください。

http://tech-wiki.pomme-verte.net/?p=32

 

mysql_secure_installationの実行

MySQLをインストールした直後は、セキュリティ的によくない部分がいくつかありますので、「mysql_secure_installation」を実行しておきましょう。 これを実行することで、以下のような設定が行えます。

  • rootユーザのパスワード変更
  • VALIDATE PASSWORDプラグインのインストール & パスワード設定
  • anonymousユーザー削除
  • リモートでのrootユーザーのログイン禁止
  • testデータベースの削除

実行すると、以下のように対話形式で設定を進めることができます。

[bash highlight="6,19,28,33,43,50,58,69"]

/usr/local/mysql/bin/mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: ※rootユーザの新しいパスワードを入力 The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password: ※rootユーザの新しいパスワードを再度入力 VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: Y ※VALIDATE PASSWORDプラグインをインストールするかを選ぶ。通常は「Y」でいいと思います。

There are three levels of password validation policy:

LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 ※パスワードの検証ポリシーを選ぶ。 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) : No ※選んだパスワード検証ポリシーでrootユーザのパスワードを変更するかを選ぶ。今回は「No」としました。 ... skipping. 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 ※anonymousユーザを削除するかどうか。「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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y ※テストデータベースを削除する。「Y」を入力します。 - Dropping test database... Success.

  • 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? (Press y|Y for Yes, any other key for No) : Y ※privilege tablesをリロードします。「Y」を入力します。 Success.

All done! [/bash]

 

VALIDATE PASSWORDプラグインについて

VALIDATE PASSWORDプラグインを有効にすることで、パスワードポリシーを選択することができます。 ポリシーは以下の3つあり、パスワードとして設定できる文字列の許容範囲が変わります。

  • LOW : 8文字以上の文字列
  • MEDIUM : 数字、アルファベット大文字・小文字の両方、特殊記号の全てを含む 8文字以上の文字列
  • STRONG : 数字、アルファベット大文字・小文字の両方、特殊記号の全てを含み、辞書ファイルに含まれない 8文字以上の文字列