Arnold Roa
Arnold Roa

Reputation: 7748

Not able to store emojis on a utf8mb mysql table

Having this table using mysql 5.7:

CREATE TABLE `emails` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subject` varchar(191) COLLATE utf8mb4_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

When I try to insert some emojis:

INSERT INTO `emails` (`from_address`, `subject`) VALUES (1, 'A😀B  C👨🏽‍🎨D')

I receive:

Incorrect string value: '\xF0\x9F\x98\x80B ...' for column 'subject' at row 1

Why? if i'm using utfmb?

Upvotes: 1

Views: 314

Answers (1)

Aaron Rumery
Aaron Rumery

Reputation: 572

Is your connection also utf8mb4? Detailed explanation of this can be found at: https://mathiasbynens.be/notes/mysql-utf8mb4

Upvotes: 2

Related Questions