MySQLのインストール方法が進化していた!

 バージョン5.6 が待望のGAとなりました!早速、あいていたサーバに入れてみました。インストール後の設定が、至れり尽くせりになっていて、びっくり!*1


 ちょっと引用が長くなるけど、敢えて途中のカットとかをしないで載せたいと思います。
あ、linux(CentOS) へのインストールです。


まず、取得したrpmのファイルを使ってインストールします。

# rpm -ivh MySQL-server-5.6.10-1.rhel5.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]

すると、数分間かけて、以下のような文字列がつらつらと表示されてきます(ここでは、コメントをいれながら、いくつかに分割して書きます)。

2013-02-06 18:38:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-02-06 18:38:36 16356 [Note] InnoDB: The InnoDB memory heap is disabled
2013-02-06 18:38:36 16356 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-02-06 18:38:36 16356 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-02-06 18:38:36 16356 [Note] InnoDB: CPU does not support crc32 instructions
2013-02-06 18:38:36 16356 [Note] InnoDB: Using Linux native AIO
2013-02-06 18:38:36 16356 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-02-06 18:38:36 16356 [Note] InnoDB: Completed initialization of buffer pool
2013-02-06 18:38:36 16356 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2013-02-06 18:38:36 16356 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2013-02-06 18:38:36 16356 [Note] InnoDB: Database physically writes the file full: wait...
2013-02-06 18:38:41 16356 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2013-02-06 18:38:47 16356 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2013-02-06 18:39:10 16356 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2013-02-06 18:39:10 16356 [Warning] InnoDB: New log files created, LSN=45781
2013-02-06 18:39:10 16356 [Note] InnoDB: Doublewrite buffer not found: creating new
2013-02-06 18:39:21 16356 [Note] InnoDB: Doublewrite buffer created
2013-02-06 18:39:21 16356 [Note] InnoDB: 128 rollback segment(s) are active.
2013-02-06 18:39:21 16356 [Warning] InnoDB: Creating foreign key constraint system tables.
2013-02-06 18:39:24 16356 [Note] InnoDB: Foreign key constraint system tables created
2013-02-06 18:39:24 16356 [Note] InnoDB: Creating tablespace and datafile system tables.
2013-02-06 18:39:28 16356 [Note] InnoDB: Tablespace and datafile system tables created.
2013-02-06 18:39:28 16356 [Note] InnoDB: Waiting for purge to start

 いろいろファイルの初期化をしてくれています。 ibdata1を12MBで作り、ib_logfile の0と1(各48MB)を作っています。ib_logfile0 はイキナリ作らずに、まず ib_logfile101 という名前で作ってからリネームしているのは何故なのでしょうね。
 その後、ダブルライトバッファを初期化し、外部キー用のシステムテーブルを作り、表領域とシステムテーブルを作成。

2013-02-06 18:39:28 16356 [Note] InnoDB: 1.2.10 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2013-02-06 18:43:36 16356 [Note] Binlog end
2013-02-06 18:43:36 16356 [Note] InnoDB: FTS optimize thread exiting.
2013-02-06 18:43:36 16356 [Note] InnoDB: Starting shutdown...
2013-02-06 18:43:38 16356 [Note] InnoDB: Shutdown completed; log sequence number 1625977

 InnoDBを開始*2して、rootパスワードをセットして InnoDB を終了。
 rootパスワードは /root/.mysql_secret ファイルに書かれています。

2013-02-06 18:43:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-02-06 18:43:38 16379 [Note] InnoDB: The InnoDB memory heap is disabled
2013-02-06 18:43:38 16379 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-02-06 18:43:38 16379 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-02-06 18:43:38 16379 [Note] InnoDB: CPU does not support crc32 instructions
2013-02-06 18:43:38 16379 [Note] InnoDB: Using Linux native AIO
2013-02-06 18:43:38 16379 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-02-06 18:43:38 16379 [Note] InnoDB: Completed initialization of buffer pool
2013-02-06 18:43:38 16379 [Note] InnoDB: Highest supported file format is Barracuda.
2013-02-06 18:43:38 16379 [Note] InnoDB: 128 rollback segment(s) are active.
2013-02-06 18:43:38 16379 [Note] InnoDB: Waiting for purge to start
2013-02-06 18:43:38 16379 [Note] InnoDB: 1.2.10 started; log sequence number 1625977
2013-02-06 18:43:38 16379 [Note] Binlog end
2013-02-06 18:43:38 16379 [Note] InnoDB: FTS optimize thread exiting.
2013-02-06 18:43:38 16379 [Note] InnoDB: Starting shutdown...
2013-02-06 18:43:40 16379 [Note] InnoDB: Shutdown completed; log sequence number 1625987

 TIMESTAMPの扱いが依然と変わっているよ、という情報を教えてくれて(詳しくはマニュアルを)、再度、InnoDBを上げて落とす*3
 あ、「ファイルフォーマットは Barracuda が超いいよ」って情報も出ていますね。バラクーダ。知っていて損はないキーワードです。私もキーワードとしてしか、知らない。


 ファイルの設定が終わって、ここからはいろんな事を教えてくれるフェーズ。

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

 mysqldに接続する際の root のパスワードは、 /root/.mysql_secret に書かれていると教えてくれています。すぐにパスワード変えろよ、それ以外の作業は、パスワード変えるまでできないぞ、と脅してきました。

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

# 

 今ハヤリの「mysql_secure_installation」を使うといいよ、と教えてくれています。いいよどころか、本番環境の場合は「強くお勧め」だそうです。"test"DB とか消してくれるそうで。
 あら。my.cnf が /etc ではなく /usr に作られているのですね。これ以前からでしたっけ?


とまぁ、随分と親切な(かつ堅牢さを意識した)作りになっていて、驚いたのでした。


 クライアントたちもインストールして、mysqldサーバを起動して、

# rpm -ivh MySQL-client-5.6.10-1.rhel5.x86_64.rpm MySQL-devel-5.6.10-1.rhel5.x86_64.rpm MySQL-shared-compat-5.6.10-1.rhel5.x86_64.rpm 
# /etc/init.d/mysql  start

 パスワードが書かれたファイルの中身を確認。

# cat /root/.mysql_secret 
 # The random password set for the root user at Wed Feb  6 18:43:34 2013 (local time): VRamRaXy

 接続。(今回、手元の環境で、さらっと動かすのに以下のように書いてしまいましたが、-p の後ろに直接パスワードを書くのは、推奨されません。接続後のWarningとしても指摘されていますね)

# mysql -uroot -pVRamRqXf
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.10

Copyright (c) 2000, 2013, 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> 

 とりあえず環境とか見てみようと思ったら、、

mysql> status
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

 インストール時に言われてしたね。パスワードを設定するまで使えないよって。なんて頑固なんでしょう。仕方ないので、パスワードをセットします。

mysql> SET PASSWORD FOR root@localhost=PASSWORD('mypass');
Query OK, 0 rows affected (0.00 sec)

 ちなみに、PASSWORD関数を咬まさないでセットしようとすると、怒られます。

mysql> SET PASSWORD FOR root@localhost='mypass';
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number

 さぁこれで、MySQL 5.6.10 (GA) が使えるようになりました!

mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.6.10, for Linux (x86_64) using  EditLine wrapper

Connection id:          2
Current database:       
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.6.10
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 23 min 10 sec

Threads: 1  Questions: 14  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.010
--------------

 まぁ my.cnf を記述して characterset とかメモリ割り当てとかInnoDBファイルに関するサイズ等の情報とかを指定する必要はあるけど、まずはここまで。


 「MySQLは(デフォルトのままで使うとパスワード設定しなくてもいいので)安全ではない(ような使い方もできる)」という指摘に対して、とにかく頑丈な安全さを提供してきたな、という印象です。
・初期パスワードをランダムでセットしてくれて
・しかもそれで接続後に、パスワードの変更をしないと使えない


 昔ながらの気軽さはなくなって来たのは寂しいけれども、確実にMySQLは進化しているな、と、インストール一本見ても、感じました。

*1:実は昨年末に超久々にインストール作業を行った時に気づいていたのですが、そのとき日記を書きそびれていたので、改めて今回初めて気づいた風の立場で書いています。あのとき何の記録も取らなかったし。

*2:ん?mysqldではなく、innodbの何らかのプロセスを動かしている?

*3:ログからは、ここで何をしているか判断つきませんね。ログシーケンス番号が10だけ進んでいるけど