19. 余談(old̲passwords= 2)
mysql57> SET old_passwords= 1;
ERROR 1231 (42000): Variable 'old_passwords' can't be set to the value of '1'
mysql57> SET old_passwords= 0;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql57> SELECT PASSWORD('abc');
+-------------------------------------------+
| PASSWORD('abc') |
+-------------------------------------------+
| *0D3CED9BEC10A777AEC23CCC353A8C08A633045E |
+-------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql57> SET old_passwords= 2;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql57> SELECT password('abc');
+----------------------------------------------------------------------+
| password('abc') |
+----------------------------------------------------------------------+
| $5$}SrJ-Kn|v#bF3m$ptR5EesAdYAcWIuJ1mTUcp91UdPT1YOMau96B76C4Y. |
+----------------------------------------------------------------------+
1 row in set, 1 warning (0.04 sec)
18/94
20. 16桁ハッシュのパスワード
mysql55> SELECT user, host, password FROM user;
+--------------+------+------------------------------------------
-+
| user | host | passwor
d |
+--------------+------+------------------------------------------
-+
| new_password | % | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC2
9 |
| old_password | % | 378b243e220ca49
3 |
+--------------+------+------------------------------------------
-+
2 rows in set (0.00 sec)
19/94
21. 5.6の時点で新しく16桁ハッシュのユーザーは作成できな
い
mysql56> SELECT @@old_passwords;
+-----------------+
| @@old_passwords |
+-----------------+
| 1 |
+-----------------+
1 row in set (0.00 sec)
mysql56> GRANT usage ON *.* TO old_password IDENTIFIED BY 'test';
ERROR 1827 (HY000): The password hash doesn't have the expected format.
Check if the correct password algorithm is being used with the PASSWORD
() function.
mysql56> GRANT USAGE ON *.* TO 'old_password'@'%' IDENTIFIED BY PASSWOR
D '378b243e220ca493';
ERROR 1827 (HY000): The password hash doesn't have the expected format.
Check if the correct password algorithm is being used with the PASSWORD
() function.
20/94
22. 16桁ハッシュのユーザーが存在する状態でアップグレー
ドした場合のみ
$ bin/mysql_upgrade
..
Warning 1642 Pre-4.1 password hash found. It is deprecated and will be remove
d in a future release. Please upgrade it to a new format.
..
mysql56> SELECT user, host, password FROM user;
+--------------+------+-------------------------------------------+
| user | host | password |
+--------------+------+-------------------------------------------+
| new_password | % | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
| old_password | % | 378b243e220ca493 |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)
21/94
23. 5.6の時点でデフォルトでは16桁ハッシュのユーザーは接
続できなくなっている
$ mysql -S /usr/mysql/5.6.25/data/mysql.sock -uold_password -ptest
Warning: Using a password on the command line interface can be insecure.
ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication prot
ocol refused (client option 'secure_auth' enabled)
$ mysql56 -uold_password -ptest --skip-secure-auth
Warning: Using a password on the command line interface can be insecure.
ERROR 1275 (HY000): Server is running in --secure-auth mode, but 'old_pa
ssword'@'localhost' has a password in the old format; please change the
password to the new format
mysql56> SET GLOBAL secure_auth= 0;
$ mysql56 -uold_password -ptest --skip-secure-auth
22/94
24. 5.7へのアップグレード時に残っている16桁ハッシュのユ
ーザーは認証できなくなる
$ mysql_upgrade -S /usr/mysql/5.7.7/data/mysql.sock -uroot
..
mysql_upgrade: [Warning] 1642: Pre-4.1 password hash found. It is deprecated and wi
ll be removed in a future release. Please upgrade it to a new format.
..
mysql57> SELECT user, host, authentication_string FROM user;
+--------------+------+-------------------------------------------+
| user | host | authentication_string |
+--------------+------+-------------------------------------------+
| new_password | % | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
| old_password | % | NULL |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)
$ mysql57 -uold_password -ptest
ERROR 1524 (HY000): Plugin 'mysql_old_password' is not loaded
23/94
26. default̲password̲lifetimeの設定
暗黙のデフォルトで360に設定されており、
password̲last̲changedから360⽇以上経過するとそのア
カウントでログインできなくなる。
mysql57> SELECT user, host, plugin, authentication_string, password_expired, password_last_changed, pas
sword_lifetime, account_locked FROM mysql.user WHERE user= 'yoku0825'G
*************************** 1. row ***************************
user: yoku0825
host: %
plugin: mysql_native_password
authentication_string: *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA
password_expired: N
password_last_changed: 1999-07-31 00:00:00
password_lifetime: NULL
account_locked: N
1 row in set (0.00 sec)
mysql57> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that support
s expired passwords.
25/94
27. default̲password̲lifetimeの値の変更
SET GLOBALでオンライン変更可能, 単位は “⽇”
0を指定することで、default̲password̲lifetimeを利⽤し
なくなる。
mysql57> SET GLOBAL default_password_lifetime= 36500;
Query OK, 0 rows affected (0.00 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
+----------------+
| current_user() |
+----------------+
| yoku0825@% |
+----------------+
mysql57> SET GLOBAL default_password_lifetime= 0;
Query OK, 0 rows affected (0.00 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
+----------------+
| current_user() |
+----------------+
| yoku0825@% |
+----------------+
26/94
28. ALTER USERによるEXPIREの制御
PASSWORD EXPIRE NEVERで無効化。
mysql.user.password̲lifetimeは0になる。-
mysql57> ALTER USER yoku0825 PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql57> SELECT user, host, plugin, authentication_string, password_expired, password_last_change
d, password_lifetime, account_locked FROM mysql.user WHERE user= 'yoku0825'G
*************************** 1. row ***************************
user: yoku0825
host: %
plugin: mysql_native_password
authentication_string: *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA
password_expired: N
password_last_changed: 1999-07-31 00:00:00
password_lifetime: 0
account_locked: N
1 row in set (0.00 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
+----------------+
| current_user() |
+----------------+
| yoku0825@% |
+----------------+
27/94
29. ALTER USERによるEXPIREの制御
PASSWORD EXPIRE DEFAULTで
default̲password̲lifetimeを使って評価するようになる。
mysql.user.password̲lifetimeがNULLになる。-
mysql57> ALTER USER yoku0825 PASSWORD EXPIRE DEFAULT;
Query OK, 0 rows affected (0.00 sec)
mysql57> SELECT user, host, plugin, authentication_string, password_expired, password_last_ch
anged, password_lifetime, account_locked FROM mysql.user WHERE user= 'yoku0825'G
*************************** 1. row ***************************
user: yoku0825
host: %
plugin: mysql_native_password
authentication_string: *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA
password_expired: N
password_last_changed: 1999-07-31 00:00:00
password_lifetime: NULL
account_locked: N
1 row in set (0.00 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client th
at supports expired passwords.
28/94
30. ALTER USERによるEXPIREの制御
PASSWORD EXPIRE INTERVAL .. DAYでパスワードのラ
イフタイムを明⽰的に指定。
password̲lifetimeには整数値が⼊る。-
飽くまでpassword̲last̲changedからの基準。-
mysql57> ALTER USER yoku0825 PASSWORD EXPIRE INTERVAL 36000 DAY;
Query OK, 0 rows affected (0.00 sec)
red, password_last_changed, password_lifetime, account_locked
FROM mysql.user WHERE user= 'yoku0825'G
*************************** 1. row ***************************
user: yoku0825
host: %
plugin: mysql_native_password
authentication_string: *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA
password_expired: N
password_last_changed: 1999-07-31 00:00:00
password_lifetime: 36000
account_locked: N
1 row in set (0.00 sec)
$ mysql57 -uyoku0825 -p -e "SELECT current_user()"
Enter password:
+----------------+
| current_user() |
+----------------+
| yoku0825@% |
+----------------+
29/94
31. SET PASSWORDの構⽂の変更
mysql57> SET PASSWORD = PASSWORD('test');
Query OK, 0 rows affected, 1 warning (0.04 sec)
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: 'SET PASSWORD = PASSWORD('<plaintext_password>')' is dep
recated and will be removed in a future release. Please use SET P
ASSWORD = '<plaintext_password>' instead
1 row in set (0.00 sec)
mysql57> SET PASSWORD = 'root';
Query OK, 0 rows affected (0.00 sec)
Syntax Errorになってしまうのは5.7.7で修正され、実⾏は
できるけどワーニングに変更。
30/94
32. SHOW GRANTSの出⼒結果
mysql56> SHOW GRANTS FOR 'sample_user'@'localhost';
Grants for sample_user@localhost
GRANT USAGE ON *.* TO 'sample_user'@'localhost' IDENTIFIED BY PAS
SWORD '*3BF184F64D4B52EF240062F6F73405B620FFF8FE'
GRANT ALL PRIVILEGES ON `db`.* TO 'sample_user'@'localhost'
2 rows in set (0.00 sec)
mysql57> SHOW GRANTS FOR 'sample_user'@'localhost';
Grants for sample_user@localhost
GRANT USAGE ON *.* TO 'sample_user'@'localhost'
GRANT ALL PRIVILEGES ON `db`.* TO 'sample_user'@'localhost'
2 rows in set (0.00 sec)
パスワードハッシュの値が出⼒されなくなった。
31/94
33. IDENTIFIED BY周りの変更
mysql57> GRANT ALL ON db.* TO grant_style@localhost IDENTIFIED BY 'test
';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql57> SHOW WARNINGSG
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: Using GRANT for creating new user is deprecated and will be rem
oved in future release. Create new user with CREATE USER statement.
1 row in set (0.00 sec)
mysql57> CREATE USER create_style@localhost IDENTIFIED BY 'test';
Query OK, 0 rows affected (0.01 sec)
mysql57> GRANT ALL ON db.* TO create_style@localhost;
Query OK, 0 rows affected (0.04 sec)
32/94
34. IDENTIFIED BY周りの変更
IDENTIFIED BY PASSWORD ʻ*..ʼ(ʻ*..ʼは41桁ハッシュさ
れたパスワード)の構⽂でもワーニングが出る。
ワーニングは出るけれど取り敢えずまだ使える。
IDENTIFIED WITH mysql̲native̲password AS ʻ*..ʼ構⽂
を使う(Authentication Pluginとか使ってて他のプラグイン
使う場合はプラグイン名読み替える)
最終的な推奨としては、CREATE USER .. IDENTIFIED
WITH mysql̲native̲password AS ʻ*..ʼ
ちなみにASはBYでもいいらしい。ワーニングメッセージに
合わせてみただけ。
33/94
35. IDENTIFIED BY周りの変更
mysql57> GRANT ALL ON db.* TO grant_style@localhost IDENTIFIED BY PASSWO
RD '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql57> SHOW WARNINGSG
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: 'IDENTIFIED BY PASSWORD' is deprecated and will be removed in
a future release. Please use IDENTIFIED WITH <plugin> AS <hash> instead
*************************** 2. row ***************************
Level: Warning
Code: 1287
Message: Using GRANT statement to modify existing user's properties othe
r than privileges is deprecated and will be removed in future release. U
se ALTER USER statement for this operation.
2 rows in set (0.00 sec)
34/94
36. IDENTIFIED BY周りの変更
mysql57> GRANT ALL ON db.* TO grant_style@localhost IDENTIFIED WI
TH mysql_native_password AS '*94BDCEBE19083CE2A1F959FD02F964C7AF4
CFC29';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql57> SHOW WARNINGSG
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: Using GRANT statement to modify existing user's properti
es other than privileges is deprecated and will be removed in fut
ure release. Use ALTER USER statement for this operation.
1 row in set (0.00 sec)
35/94
37. IDENTIFIED BY周りの変更
mysql57> CREATE USER create_style@localhost IDENTIFIED BY PASSWOR
D '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql57> SHOW WARNINGSG
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: 'IDENTIFIED BY PASSWORD' is deprecated and will be remov
ed in a future release. Please use IDENTIFIED WITH <plugin> AS <h
ash> instead
1 row in set (0.00 sec)
36/94
42. NO̲ZERO̲IN̲DATE
mysql56> SET sql_mode= CONCAT_WS(',', @@sql_mode, 'NO_ZERO_IN_DATE');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql56> INSERT INTO t1 VALUES ('2015-00-31');
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql56> SHOW WARNINGS;
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'dt' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)
mysql56> SELECT * FROM t1;
+---------------------+
| dt |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
NO̲ZERO̲DATEとは別物
41/94
43. NO̲ZERO̲IN̲DATE + strict̲mode
mysql56> SET sql_mode= CONCAT_WS(',', @@sql_mode, 'STRICT_TRANS_T
ABLES');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql56> INSERT INTO t1 VALUES ('2015-00-31');
ERROR 1292 (22007): Incorrect datetime value: '2015-00-31' for co
lumn 'dt' at row 1
ワーニングがエラーにエスカレーションされる。
42/94
44. ONLY̲FULL̲GROUP̲BY
何故MySQLは今までこんなクエリーを許していたのかよく
わからない感じのものが
mysql56> SELECT val, num, COUNT(*) AS c FROM t1 GROUP BY val ORDE
R BY c DESC LIMIT 5;
+--------------------------------------+-----+---+
| val | num | c |
+--------------------------------------+-----+---+
| 人類はストラトス | 16 | 8 |
| 僕は友達が巨人 | 333 | 7 |
| アウトブレイクストラトス | 46 | 7 |
| さんをつけろよマスター | 39 | 7 |
| 電波女と衰退しました | 140 | 7 |
+--------------------------------------+-----+---+
5 rows in set (0.04 sec)
43/94
45. ONLY̲FULL̲GROUP̲BY
ちゃんとエラーになる。
mysql56> SET sql_mode= CONCAT_WS(',', @@sql_mode, 'ONLY_FULL_GROU
P_BY');
Query OK, 0 rows affected (0.00 sec)
mysql56> SELECT val, num, COUNT(*) AS c FROM t1 GROUP BY val ORDE
R BY c DESC LIMIT 5;
ERROR 1055 (42000): 'd1.t1.num' isn't in GROUP BY
ONLY̲FULL̲GROUP̲BYはsql̲modeから取り除かれ、標準
動作になる予定
44/94
46. 誰得ANY̲VALUE関数
5.7の⽅がちょっとエラーメッセージが親切
そして何故そんな関数を作ろうと思っちゃったのか。
mysql57> SELECT @@sql_modeG
*************************** 1. row ***************************
@@sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
1 row in set (0.00 sec)
mysql57> SELECT val, num, COUNT(*) AS c FROM t1 GROUP BY val ORDER BY c DESC LIMIT 5;
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonag
gregated column 'd1.t1.num' which is not functionally dependent on columns in GROUP BY claus
e; this is incompatible with sql_mode=only_full_group_by
mysql57> SELECT val, ANY_VALUE(num), COUNT(*) AS c FROM t1 GROUP BY val ORDER BY c DESC LIMI
T 5;
+--------------------------------------+----------------+---+
| val | ANY_VALUE(num) | c |
+--------------------------------------+----------------+---+
| 人 類 は ス ト ラ ト ス | 16 | 8 |
| 僕 は 友 達 が 巨 人 | 333 | 7 |
| ア ウ ト ブ レ イ ク ス ト ラ ト ス | 46 | 7 |
| さ ん を つ け ろ よ マ ス タ ー | 39 | 7 |
| 電 波 女 と 衰 退 し ま し た | 140 | 7 |
+--------------------------------------+----------------+---+
5 rows in set (0.01 sec)
45/94
47. NO̲AUTO̲CREATE̲USER
mysql56> GRANT replication slave ON *.* TO u1;
Query OK, 0 rows affected (0.00 sec)
mysql56> SET sql_mode= CONCAT_WS(',', @@sql_mode, 'NO_AUTO_CREATE
_USER');
Query OK, 0 rows affected (0.00 sec)
mysql56> GRANT replication slave ON *.* TO u2;
ERROR 1133 (42000): Can't find any matching row in the user table
mysql56> CREATE USER u2;
Query OK, 0 rows affected (0.00 sec)
mysql56> GRANT replication slave ON *.* TO u2;
Query OK, 0 rows affected (0.00 sec)
NO̲AUTO̲CREATE̲USERもsql̲modeから取り除かれ、標
準動作になる予定
46/94
48. sql̲modeが空でも
mysql56> SELECT @@sql_mode;
+------------+
| @@sql_mode |
+------------+
| |
+------------+
1 row in set (0.00 sec)
mysql56> CREATE TABLE t1 (num int default null, PRIMARY KEY(num));
Query OK, 0 rows affected (0.16 sec)
mysql57> SELECT @@sql_mode;
+------------+
| @@sql_mode |
+------------+
| |
+------------+
1 row in set (0.00 sec)
mysql57> CREATE TABLE t1 (num int default null, PRIMARY KEY(num));
ERROR 1171 (42000): All parts of a PRIMARY KEY must be NOT NULL; if you need NUL
L in a key, use UNIQUE instead
MySQL 5.7.3 m13 does not allow DEFAULT NULL for
primary key ・ Issue #13203 ・ rails/rails
47/94
57. 明⽰, 暗黙のテンポラリーテーブルにInnoDBがデフォル
トで使われる
MyISAMを使⽤した暗黙のテンポラリーテーブルがあふれた
場合
mysql57> SELECT * FROM (SELECT * FROM t1 WHERE val LIKE 'abc%') A
S t1, (SELECT * FROM t1 WHERE val LIKE 'def%') AS t2 ORDER BY t1.
num;
ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_2974_
0.MYI'; try to repair it
$ tail error.log
..
2015-04-30T14:59:45.558360+09:00 87 [ERROR] /usr/mysql/5.7.7/bin/
mysqld: Incorrect key file for table '/tmp/#sql_2974_0.MYI'; try
to repair it
2015-04-30T14:59:45.573411+09:00 87 [ERROR] Got an error from unk
nown thread, /home/yoku0825/mysql-5.7.7-rc/storage/myisam/mi_writ
e.c:223
56/94
58. 明⽰, 暗黙のテンポラリーテーブルにInnoDBがデフォル
トで使われる
InnoDBを使⽤した暗黙のテンポラリーテーブルがあふれた
場合
mysql57> SELECT * FROM (SELECT * FROM t1 WHERE val LIKE 'abc%') AS t1,
(SELECT * FROM t1 WHERE val LIKE 'def%') AS t2 ORDER BY t1.num;
ERROR 1114 (HY000): The table '/tmp/#sql_2974_0' is full
$ tail error.log
..
2015-04-30T15:04:22.549484+09:00 87 [ERROR] InnoDB: posix_fallocate(): F
ailed to preallocate data for file ./ibtmp1, desired size 67108864 byte
s. Operating system error number 28. Check that the disk is not full or
a disk quota exceeded. Make sure the file system supports this functio
n. Some operating system error numbers are described at http://dev.mysq
l.com/doc/refman/5.7/en/operating-system-error-codes.html
2015-04-30T15:04:22.590070+09:00 87 [Warning] InnoDB: 1048576 bytes shou
ld have been written. Only 794624 bytes written. Retrying again to writ
e the rem
57/94
60. log̲timestamps変数によるログ上のタイムスタンプの
UTC化
こんなクエリーがあるじゃろ︖ (AA略)
mysql57> SET SESSION binlog_format= STATEMENT;
Query OK, 0 rows affected (0.00 sec)
mysql57> SELECT NOW(); INSERT INTO t1 SELECT * FROM t1 ORDER BY
RAND() LIMIT 1;
+---------------------+
| NOW() |
+---------------------+
| 2015-03-09 14:01:02 |
+---------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected, 3 warnings (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 3
59/94
61. log̲timestamps変数によるログ上のタイムスタンプの
UTC化
エラーログ
$ tail data/error.log
..
2015-03-09T05:01:02.713955Z 14 [Warning] Unsafe statement written to the binary
log using statement format since BINLOG_FORMAT = STATEMENT. The statement is uns
afe because it uses a LIMIT clause. This is unsafe because the set of rows inclu
ded cannot be predicted. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER BY RAN
D() LIMIT 1
2015-03-09T05:01:02.713987Z 14 [Warning] Unsafe statement written to the binary
log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe
because it uses a system function that may return a different value on the slav
e. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER BY RAND() LIMIT 1
2015-03-09T05:01:02.714000Z 14 [Warning] Unsafe statement written to the binary
log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing t
o a table with an auto-increment column after selecting from another table are u
nsafe because the order in which rows are retrieved determines what (if any) row
s will be written. This order cannot be predicted and may differ on master and t
he slave. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER BY RAND() LIMIT 1
60/94
62. log̲timestamps変数によるログ上のタイムスタンプの
UTC化
スローログ
$ tail data/slow.log
..
# Time: 2015-03-09T05:01:02.714121Z
# User@Host: root[root] @ localhost [] Id: 14
# Query_time: 0.000633 Lock_time: 0.000215 Rows_sent: 0 Rows_ex
amined: 0
SET timestamp=1425877262;
INSERT INTO t1 SELECT * FROM t1 ORDER BY RAND() LIMIT 1;
# Time: 2015-03-09T05:01:06.197098Z
# User@Host: root[root] @ localhost [] Id: 14
# Query_time: 0.000168 Lock_time: 0.000000 Rows_sent: 0 Rows_ex
amined: 0
SET timestamp=1425877266;
SHOW WARNINGS;
61/94
65. log̲timestamps変数によるログ上のタイムスタンプの
UTC化
+09:00がオフセットとして追加される。
$ tail data/error.log
..
2015-03-09T14:03:16.606892+09:00 14 [Warning] Unsafe statement written to the bi
nary log using statement format since BINLOG_FORMAT = STATEMENT. The statement i
s unsafe because it uses a LIMIT clause. This is unsafe because the set of rows
included cannot be predicted. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER B
Y RAND() LIMIT 1
2015-03-09T14:03:16.606932+09:00 14 [Warning] Unsafe statement written to the bi
nary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is un
safe because it uses a system function that may return a different value on the
slave. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER BY RAND() LIMIT 1
2015-03-09T14:03:16.606948+09:00 14 [Warning] Unsafe statement written to the bi
nary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writ
ing to a table with an auto-increment column after selecting from another table
are unsafe because the order in which rows are retrieved determines what (if any
) rows will be written. This order cannot be predicted and may differ on master
and the slave. Statement: INSERT INTO t1 SELECT * FROM t1 ORDER BY RAND() LIMIT
1
64/94
77. secure̲file̲privの変更
SELECT .. INTO OUTFILE .. や LOAD DATA INFILE ..,
LOAD̲FILE関数の動作を制限。
指定されていない場合 .. mysqldの実効ユーザー権限で全てのファイ
ルにアクセス可能
5.6までの暗黙のデフォルト, 5.7でもビルド⽅法によってはこれ(バイナリー
の.tar.gz, ソースからのコンパイルはここ)
-
指定されている場合 .. 指定されたディレクトリ以下のみ、FILE権限
を利⽤する操作が可能。
rpm, debなどのパッケージものの場合、5.7から暗黙のデフォルトが/var/lib/
mysql-filesに設定される
-
(new) NULLが指定されている場合 .. FILE権限を利⽤する操作は全て
不可能。
-
MySQL :: MySQL 5.7 Reference Manual :: 5.1.3 Server
Command Options
76/94
78. secure̲file̲privの変更
secure̲file̲privの動作そのものにはそれほど変わりがな
い。
mysql56> SELECT @@global.secure_file_priv;
+--------------------+
| @@secure_file_priv |
+--------------------+
| /tmp/ |
+--------------------+
1 row in set (0.00 sec)
mysql56> SELECT 1 INTO OUTFILE '/home/mysql/test.txt';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p
riv option so it cannot execute this statement
mysql56> SELECT LOAD_FILE('/etc/hosts');
+-------------------------+
| LOAD_FILE('/etc/hosts') |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.02 sec)
77/94
82. オプションの前⽅⼀致保管
今までは、たとえば–sockから–socketを保管してくれてい
た
mysqldに限らず、他のコマンドラインクライアント類も同様。-
$ bin/mysqld_safe --no-defaults --sock=/tmp/mysql.sock &
..
2015-06-08 14:57:11 0 [Warning] Using unique option prefix sock
instead of socket is deprecated and will be removed in a future
release. Please use the full name instead.
..
5.7ではunknown variableとしてエラーになる
$ bin/mysqld_safe --no-defaults --sock=/tmp/mysql.sock &
..
2015-06-08T05:58:16.223276Z 0 [ERROR] unknown variable 'sock=/tmp/mysql.sock'
..
81/94
83. スローログ関連の閾値が⼤幅に変更される かも
5.7.7-rc現在でまだ “プロポーザル” だが、最初のプロポー
ザルから既にいくつも新しいデフォルトとして反映されてい
るので要チェック。
Proposal to change additional defaults in MySQL 5.7 Master
MySQL
-
Proposal to change additional defaults in MySQL 5.7 (February
Edition) Master MySQL
-
log̲slow̲admin̲statements
log̲slow̲slave̲statements
long̲query̲time(10 => 2)
log̲queries̲not̲using̲indexes
min̲examined̲row̲limit(0 => 1000)
82/94