GA

2015/03/10

MySQL 5.7.6でデータベースの初期化が変わる mysql_install_dbからmysqld --initialize

MySQL 5.7.6のメモその1。
MySQLの初期化がmysql_install_dbからmysqld --initializeに変わる。


リリースノートのいわく、

mysql_install_db functionality now has been integrated into the MySQL server, mysqld. To initialize a MySQL installation, invoke mysqld with the --initialize or --initialize-insecure option, depending on whether you want the server to generate a random password for the initial 'root'@'localhost' account. (The server writes the password to its error log.)

MySQL :: MySQL 5.7 Release Notes :: Changes in MySQL 5.7.6 (Not yet released, Milestone 16)


だそうで。

deprecatedなのでまだ使えるものの、若干挙動は違う。
まずはmysql_install_db。


[root@v157-7-154-209 mysql]# ./bin/mysql_install_db --no-defaults -vvvv --datadir=./data --basedir=./ --user=mysql
2015-02-17 11:01:21 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-02-17 11:01:21 [NOTE]    Creating data directory ./data
2015-02-17 11:01:21 [NOTE]    Generating random password to /root/.mysql_secret...done.
2015-02-17 11:01:21 [NOTE]    Setting file ownership to mysql
2015-02-17 11:01:21 [NOTE]    Executing /usr/local/mysql/bin/mysqld --no-defaults --bootstrap --datadir=./data --lc-messages-dir=./share --lc-messages=en_US --basedir=.
2015-02-17 11:01:22 [NOTE]    Creating system tables...done.
2015-02-17 11:01:22 [NOTE]    Filling system tables with data...done.
2015-02-17 11:01:22 [NOTE]    Filling help table with data...done.
2015-02-17 11:01:22 [NOTE]    Creating default user root@localhost
2015-02-17 11:01:22 [NOTE]    Creating default proxy root@localhost
2015-02-17 11:01:22 [WARNING] The bootstrap log isn't empty:
2015-02-17 11:01:22 [WARNING] mysqld: [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2015-02-17 11:01:22 [NOTE]    Generating SSL Certificates
[root@v157-7-154-209 mysql]# OpenSSL 1.0.1e-fips 11 Feb 2013
server-cert.pem: OK
client-cert.pem: OK

server-cert.pemとclient-cert.pemも一緒に作ってくれるようになったようだ。datadirの下にある。


[root@v157-7-154-209 mysql]# ll data
total 110636
-rw-r--r-- 1 root  root      1679 Feb 17 11:01 ca-key.pem
-rw-r--r-- 1 root  root      1082 Feb 17 11:01 ca.pem
-rw-r--r-- 1 root  root       948 Feb 17 11:01 ca-req.pem
-rw-r--r-- 1 root  root      1086 Feb 17 11:01 client-cert.pem
-rw-r--r-- 1 root  root      1679 Feb 17 11:01 client-key.pem
-rw-r--r-- 1 root  root       956 Feb 17 11:01 client-req.pem
-rw-r----- 1 mysql mysql 12582912 Feb 17 11:01 ibdata1
-rw-r----- 1 mysql mysql 50331648 Feb 17 11:01 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Feb 17 11:01 ib_logfile1
drwxr-x--- 2 mysql mysql     4096 Feb 17 11:01 mysql
drwxr-x--- 2 mysql mysql     4096 Feb 17 11:01 performance_schema
-rw-r--r-- 1 root  root      1086 Feb 17 11:01 server-cert.pem
-rw-r--r-- 1 root  root      1679 Feb 17 11:01 server-key.pem
-rw-r--r-- 1 root  root       956 Feb 17 11:01 server-req.pem


次にmysqld --initialize。

[root@v157-7-154-209 mysql]# bin/mysqld --no-defaults --user=mysql --initialize --log-error-verbosity=3
2015-02-17T02:07:18.459528Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-02-17T02:07:18.459579Z 0 [Note] Ignoring --secure-file-priv value as server is running with --initialize(-insecure) or --bootstrap.
2015-02-17T02:07:18.459603Z 0 [Note] bin/mysqld (mysqld 5.7.6-m16) starting as process 9522 ...
2015-02-17T02:07:18.461416Z 0 [Note] Creating the data directory /usr/local/mysql/data/
2015-02-17T02:07:18.462889Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-02-17T02:07:18.462907Z 0 [Note] InnoDB: Uses event mutexes
2015-02-17T02:07:18.462912Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2015-02-17T02:07:18.462916Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-02-17T02:07:18.462920Z 0 [Note] InnoDB: Using Linux native AIO
2015-02-17T02:07:18.463183Z 0 [Note] InnoDB: Number of pools: 1
2015-02-17T02:07:18.463289Z 0 [Note] InnoDB: Using CPU crc32 instructions
2015-02-17T02:07:18.464373Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2015-02-17T02:07:18.482783Z 0 [Note] InnoDB: Completed initialization of buffer pool
2015-02-17T02:07:18.485348Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2015-02-17T02:07:18.485417Z 0 [Note] InnoDB: page_cleaner coordinator priority: -20
2015-02-17T02:07:18.485766Z 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2015-02-17T02:07:18.507795Z 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2015-02-17T02:07:18.508209Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-02-17T02:07:18.581890Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-02-17T02:07:18.680378Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-02-17T02:07:18.680429Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-02-17T02:07:18.680440Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2015-02-17T02:07:18.680466Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2015-02-17T02:07:18.698804Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2015-02-17T02:07:18.699054Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-02-17T02:07:18.716545Z 0 [Note] InnoDB: Doublewrite buffer created
2015-02-17T02:07:18.723409Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2015-02-17T02:07:18.723423Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2015-02-17T02:07:18.723658Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-02-17T02:07:18.729190Z 0 [Note] InnoDB: Foreign key constraint system tables created
2015-02-17T02:07:18.729218Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-02-17T02:07:18.730392Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2015-02-17T02:07:18.730458Z 0 [Note] InnoDB: Waiting for purge to start
2015-02-17T02:07:18.781741Z 0 [Note] InnoDB: 5.7.6 started; log sequence number 0
2015-02-17T02:07:18.782142Z 0 [Note] Plugin 'FEDERATED' is disabled.
2015-02-17T02:07:18.782426Z 0 [Warning] Failed to setup SSL
2015-02-17T02:07:18.782433Z 0 [Warning] SSL error: SSL context is not usable without certificate and private key
2015-02-17T02:07:18.782831Z 1 [Note] Creating the system database
2015-02-17T02:07:18.782984Z 1 [Warning] A temporary password is generated for root@localhost: wokeG8n=Joia
2015-02-17T02:07:18.783207Z 1 [Note] Creating the system tables
2015-02-17T02:07:19.296188Z 1 [Note] Filling in the system tables, part 1
2015-02-17T02:07:19.296627Z 1 [Note] Filling in the system tables, part 2
2015-02-17T02:07:19.296635Z 1 [Note] Filling in the mysql.help table
2015-02-17T02:07:19.616979Z 1 [Note] Bootstrapping complete
2015-02-17T02:07:19.617114Z 0 [Note] Giving 0 client threads a chance to die gracefully
2015-02-17T02:07:19.617129Z 0 [Note] Shutting down slave threads
2015-02-17T02:07:19.617134Z 0 [Note] Forcefully disconnecting 0 remaining clients
2015-02-17T02:07:19.617262Z 0 [Note] Binlog end
2015-02-17T02:07:19.617512Z 0 [Note] InnoDB: FTS optimize thread exiting.
2015-02-17T02:07:19.617549Z 0 [Note] InnoDB: Starting shutdown...
2015-02-17T02:07:21.328813Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2338738
2015-02-17T02:07:21.331690Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"

ちゃんとやってくれてるぽいんだけど、パスワードを標準エラー出力に吐いていて、~/.mysql_secretは作ってくれない。
(mysql_install_dbは相変わらず作る)
あとなんか証明書の作成に転けてる。なんだろう。

[root@v157-7-154-209 mysql]# cat ~/.mysql_secret
cat: /root/.mysql_secret: No such file or directory

chefとか、.mysql_secretをゴニョゴニョしていた人たちは標準エラー出力(not 標準出力)から取らないといけないので面倒そう。
バイナリーとかソースから入れて自分でmysql_install_dbを叩いていたぶんには言いとして、rpmとかで入れるとこの辺勝手にやりそうだしなぁ。。

mysql_install_db --insecure相当のオプションもある。--initialize-insecureだ。


[root@v157-7-154-209 mysql]# bin/mysqld --no-defaults --log-error-verbosity=3 --initialize-insecure
..
2015-02-17T02:15:08.272387Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
..

なお 日々の覚書: MySQL 5.7.5 on Windowsでskip-name-resolveするとrootでログインできなくなる で触れたような、

admin-auth-plugin                 mysql_native_password
admin-host                        localhost
admin-require-ssl                 FALSE
admin-user                        root

mysql_install_dbのこの辺に相当するオプションはパッと見ない模様。


とりあえずmysqld --initialize-insecureが流行る予感。rpmの時は気をつけろ。標準エラー出力を取りこぼしたら--skip-grant-tablesで立ち上げるしかなくなるぞ!(たぶん)

1 件のコメント :

  1. Thanks for providing this informative information you may also refer http://www.s4techno.com/blog/2015/12/23/difference-mysql-ce-mysql-enterprise-edition/

    返信削除