Let MySQL support emoji emoticons, involving wireless-related MySQL database recommendations are in advance with the UTF8MB4 character set.
What's the difference between utf8mb4 and UTF8? The original MySQL UTF8 a character up to 3 bytes, while the UTF8MB4 expands to a character up to 4 bytes, so it can support more character sets.
Solution: Convert the MySQL encoding from UTF8 to UTF8MB4.
Requires >= MySQL 5.5.3 version, from the library must be 5.5, the lower version does not support this character set, copy error
Stop the MySQL Server service
Modify MY.CNF or Mysql.ini
[Client]
Default-character-set = Utf8mb4
[MySQL]
Default-character-set = Utf8mb4
[Mysqld]
Character-set-client-handshake = FALSE
Character-set-server = Utf8mb4
Collation-server = Utf8mb4_unicode_ci
init_connect= ' SET NAMES utf8mb4 '
Restart MySQL Server, check the character set
mysql> SHOW VARIABLES WHERE variable_name like ' character\_set\_% ' OR variable_name like ' collation% ';
To modify the database character set:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
To modify the character set of a table:
ALTER TABLE table_name CONVERT to CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
To modify the character set of a field:
ALTER TABLE table_name Change column_name column_name VARCHAR (191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
If it's just a field, you just need to modify that field's character set.
In addition to the connection parameters of the server connection database connector/j, do not add characterencoding parameters. When this parameter is not added, the default value is AutoDetect.
Let MySQL support emoji emoticons