Closed it-walker closed 3 years ago
utf8になっていない。
mysql> show create database development; +-------------+------------------------------------------------------------------------+ | Database | Create Database | +-------------+------------------------------------------------------------------------+ | development | CREATE DATABASE `development` /*!40100 DEFAULT CHARACTER SET latin1 */ | +-------------+------------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> show create table users; +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | users | CREATE TABLE `users` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `age` int(11) NOT NULL, `email` varchar(255) NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, `deletedAt` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> alter table users default character set utf8mb4; Query OK, 0 rows affected (0.00 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table users; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | users | CREATE TABLE `users` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET latin1 NOT NULL, `age` int(11) NOT NULL, `email` varchar(255) CHARACTER SET latin1 NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, `deletedAt` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> alter database development character set utf8mb4 collate utf8mb4_general_ci; Query OK, 1 row affected (0.00 sec)
mysql> show create database development; +-------------+-------------------------------------------------------------------------+ | Database | Create Database | +-------------+-------------------------------------------------------------------------+ | development | CREATE DATABASE `development` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ | +-------------+-------------------------------------------------------------------------+ 1 row in set (0.00 sec)
実行結果
実施前
utf8になっていない。
対応後