আমি মাইএসকিউএল 5.5.21 এ আছি এবং '\ xF0 \ x9F \ x98 \ x8A' স্মাইলি মুখের চরিত্রটি sertোকানোর চেষ্টা করছি। তবে আমার জীবনের জন্য, আমি কীভাবে এটি করব তা বুঝতে পারি না।
বিভিন্ন ফোরামে যেগুলি আমি পড়ছি তা অনুসারে এটি সম্ভব। তবে যখনই আমি এটি চেষ্টা করি তখনই ডেটাটি কেটে যায়।
mysql> INSERT INTO hour ( `title`, `content`, `guid` , `published` , `lang` , `type` ,
`indegree` , `lon` , `lat` , `state` , `country` , `hour` )
VALUES ( "title" , "content 😊 content" , "guid" , 1, 1,
"WEBLOG", 1, 1, 1, "state" , "country" , 1 );
Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\xF0\x9F\x98\x8A ...' for column 'content' at row 1 |
| Warning | 1265 | Data truncated for column 'published' at row 1 |
+---------+------+-------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> select LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| 687302 |
+------------------+
1 row in set (0.00 sec)
mysql> select * from hour where id = 687302;
+--------+-------+----------+------+---------------------+
| id | title | content | guid | published |
+--------+-------+----------+------+---------------------+
| 687302 | title | content | guid | 0000-00-00 00:00:00 |
+--------+-------+----------+------+---------------------+
1 row in set (0.00 sec)
তবে আমার টেবিলের সংজ্ঞাটি নিম্নরূপ।
CREATE TABLE `hour` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 NOT NULL,
`content` text CHARACTER SET utf8 NOT NULL,
`guid` varchar(255) CHARACTER SET utf8 NOT NULL,
`published` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lang` tinyint(3) unsigned NOT NULL,
`type` enum('WEBLOG','MICROBLOG') CHARACTER SET utf8 DEFAULT NULL,
`indegree` int(4) unsigned NOT NULL,
`lon` float DEFAULT NULL,
`lat` float DEFAULT NULL,
`state` varchar(50) CHARACTER SET utf8 DEFAULT '',
`country` varchar(50) CHARACTER SET utf8 DEFAULT '',
`hour` int(2) DEFAULT NULL,
`gender` enum('MALE','FEMALE') CHARACTER SET utf8 DEFAULT NULL,
`time_zone` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MEMORY AUTO_INCREMENT=687560 DEFAULT CHARSET=utf8mb4 KEY_BLOCK_SIZE=288
কেউ দেখতে পাবে যে আমি CHARSET = utf8mb4 ব্যবহার করছি। নিশ্চয় এটি মাল্টি-বাইট অক্ষর ব্যবহারের চারপাশে সমস্যাগুলি সংশোধন করে?
ঠিক আছে, তাই আমি লক্ষ্য করিনি:
`content` text CHARACTER SET utf8 NOT NULL,
আমি এখন এটি সংশোধন করেছি, কিন্তু এখনও মজার ফলাফল পেতে।
CREATE TABLE `hourtmp` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 NOT NULL,
`content` text NOT NULL,
`guid` varchar(255) CHARACTER SET utf8 NOT NULL,
`published` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lang` tinyint(3) unsigned NOT NULL,
`type` enum('WEBLOG','MICROBLOG') CHARACTER SET utf8 DEFAULT NULL,
`indegree` int(4) unsigned NOT NULL,
`lon` float DEFAULT NULL,
`lat` float DEFAULT NULL,
`state` varchar(50) CHARACTER SET utf8 DEFAULT '',
`country` varchar(50) CHARACTER SET utf8 DEFAULT '',
`hour` int(2) DEFAULT NULL,
`gender` enum('MALE','FEMALE') CHARACTER SET utf8 DEFAULT NULL,
`time_zone` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MEMORY AUTO_INCREMENT=687563 DEFAULT CHARSET=utf8mb4 KEY_BLOCK_SIZE=288 |
mysql> INSERT INTO hourtmp ( `title`, `content`, `guid` , `published` , `lang` , `type` , `indegree` ,
`lon` , `lat` , `state` , `country` , `hour` ) VALUES ( "title" , "content 😊 content" ,
"guid" , 1, 1, "WEBLOG", 1, 1, 1, "state" , "country" , 1 );
Query OK, 1 row affected, 2 warnings (0.00 sec)
mysql> show warnings;
| Level | Code | Message |
| Warning | 1366 | Incorrect string value: '\xF0\x9F\x98\x8A ...' for column 'content' at row 1 |
| Warning | 1265 | Data truncated for column 'published' at row 1 |
2 rows in set (0.00 sec)
mysql> select * from hourtmp;
+--------+-------+-----------------------+
| id | title | content |
+--------+-------+-----------------------+
| 687560 | title | content ???? content |
| 687561 | title | content ???? content |
+--------+-------+-----------------------+
uft8
TEXT