Quantcast
Channel: 日々の覚書
Viewing all articles
Browse latest Browse all 581

すごくどうでもいいかもしれないMySQL 5.7の変更点 in mysql_install_db

$
0
0
取り合えず、PerlからCに変わってる。

$ file /usr/mysql/5.6.20/scripts/mysql_install_db
/usr/mysql/5.6.20/scripts/mysql_install_db: a /usr/bin/perl script text executable

$ file /usr/mysql/5.7.5/bin/mysql_install_db
/usr/mysql/5.7.5/bin/mysql_install_db: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped


あと、パスが変わってる。今までは./scriptsだったのが./binに(rpmで使ってるぶんには何も変わらないはず) ソースの位置もclient/mysql_install_db.ccになってる。

増えたオプションがいっぱい。

$ /usr/mysql/5.7.5/bin/mysql_install_db --help
..
--admin-auth-plugin=name
Plugin to use for the default admin account.
--admin-host=name Hostname part of the default admin account.
--admin-require-ssl Require SSL/TLS for the default admin account.
--admin-user=name Username part of the default admin account.
..
--defaults Read any option files from default location. If program
startup fails due to reading unknown options from an
option file, --no-defaults can be used to prevent them
from being read.
..
-f, --extra-sql-file=name
Optional SQL file to execute during bootstrap.
--insecure Disables random passwords for the default admin account.
..
--lc-messages=name Specifies the language to use.
-l, --lc-messages-dir=name
Specifies the path to the language files.
--login-file=name Use the MySQL password store at the specified location
to set the default password. This option takes precedence
over admin-user, admin-host options. Use the login-path
option to change the default credential category (default
is 'client').
--login-path=name Set the credential category to use with the MySQL
password store when setting default credentials. This
option takes precedence over admin-user, admin-host
options.
--mysqld-file=name Qualified path to the mysqld binary.
--random-password-file=name
Specifies the qualified path to the .mysql_secret
temporary password file.
..


.mylogin.cnf周りっぽいやつが軒並み追加。あと、5.6.20で折角追加された--keep-my-cnfがいきなりなくなってるけど、そもそもmy.cnfを勝手に作るロジックがなくなったような気がする(けど、support-files/my-default.cnfはまだ残ってるな)
敢えて/etc/my.cnfとか/usr/local/mysql/etc/my.cnfとかを読むであろう、--defaultsとかいうオプションも追加されてる。誰得。。

extra-sql-fileとかいうのを上手く使うと、mysql_install_dbの段階でユーザーを初期設定できたりするのかしらん? と思ったら


$ cat ./test.sql
GRANT ALL ON tpcc.* TO tpcc@localhost IDENTIFIED BY 'tpcc';

$ ./bin/mysql_install_db --datadir=./data --basedir=./ --extra-sql-file=./test.sql
2014-10-07 18:35:26 [ERROR] The bootstrap log isn't empty:
2014-10-07 18:35:26 [ERROR] 2014-10-07T09:35:25.177361Z 1 [ERROR] 1290 The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
2014-10-07T09:35:25.177637Z 0 [ERROR] Aborting


--bootstrapしてる状態で食わせるから、GRANTステートメントはダメか。
CREATE DATABASEとかはどうだ。

$ cat test2.sql
CREATE DATABASE tpcc;

$ ./bin/mysql_install_db --datadir=./data --basedir=./ --extra-sql-file=./test2.sql

$ ll data
合計 110612
-rw-rw---- 1 yoku0825 yoku0825 50331648 10月 7 18:37 2014 ib_logfile0
-rw-rw---- 1 yoku0825 yoku0825 50331648 10月 7 18:37 2014 ib_logfile1
-rw-rw---- 1 yoku0825 yoku0825 12582912 10月 7 18:37 2014 ibdata1
drwx------ 2 yoku0825 yoku0825 4096 10月 7 18:37 2014 mysql
drwx------ 2 yoku0825 yoku0825 4096 10月 7 18:37 2014 performance_schema
drwx------ 2 yoku0825 yoku0825 4096 10月 7 18:37 2014 tpcc


通ったってことは、GRANTをmysql.user, dbあたりへのINSERTステートメントにすれば食えるだろうけど、微妙だなぁ。。

--insecureはrootのランダムパスワード生成を無効化してくれるので、好んで使う人多いんじゃないでしょうか :)
5.6までは--random-passwordがオプション扱いだった(rpm -iの時にこのオプションが押し込まれる)けれど、5.7では逆に--insecureがないと常にランダムパスワード生成ぽい。

あと、5.6までは--basedirを与えない時は暗黙にカレントディレクトリがbasedirだったのが、5.7では明示的に与えないといけない。


$ ./bin/mysql_install_db --datadir=./data
2014-10-07 18:44:41 [ERROR] Can't locate the language directory.

暗黙のbasedirが与えられてないから、$basedir/shareが見つからずにこんなん言われる。慣れてるからすぐわかるけど、初心者殺しな罠だと思うこれ。

Viewing all articles
Browse latest Browse all 581

Trending Articles