1

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, 'AB  Cā€D')

I receive:

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

Why? if i'm using utfmb?

Arnold Roa
  • 7,335
  • 5
  • 50
  • 69
  • Possible duplicate of [How to store Emoji Character in My SQL Database](https://stackoverflow.com/questions/39463134/how-to-store-emoji-character-in-my-sql-database) – Dez Mar 24 '18 at 19:01
  • 1
    Relevant is the third answer on the linked question with `SET NAMES utf8mb4`. http://sqlfiddle.com/#!9/d0bbce/1 – Paul Spiegel Mar 24 '18 at 19:03

1 Answers1

2

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

Aaron Rumery
  • 552
  • 2
  • 9