Tag: MySQL8/utf8mb4
collation-server=utf8mb4_bin
create database testdb default charset=utf8mb4 collate=utf8mb4_bin
DROP TABLE IF EXISTS test_table; create table test_table( title varchar(255) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
mysql> show create table test_table; +------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | test_table | CREATE TABLE `test_table` ( `title` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | +------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> show create table test_table; +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | test_table | CREATE TABLE `test_table` ( `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
※collateがデフォルトのままだとこのような挙動は発生しないが、utf8mb4_binを使う以上はさけられないのか?