Upgrade MySql to support emoji and utf8mb4

Source: Internet
Author: User

Upgrade MySql to support emoji and utf8mb4

Some children's shoes do not have a deep understanding of Emoji expressions. They are reluctant to use Emoji and do not want to go to Baidu.

Emoji is a character, not an image. If it is not supported by the client or database, upgrade it. the browser is also used. Since it is a character, can it be replaced manually? Yes. In fact, you can upgrade the relevant component version. Emoji is not Apple's exclusive expression. It belongs to unicode and is a standard, not a private solution. Everyone can use it happily without conversion.

-- In fact, this simple problem is always drunk.

However, even upgrading mysql is not easy. I thought it would be okay to upgrade the database and change the encoding, but it was not that easy after the test. I don't know if it is a problem with the MySql client. The same is true for NativeCat and the official Workbench.

The client adaptation is not feasible ...... The drop-down menu does not support any choice ......

References:

Http://bbs.csdn.net/topics/390055415http://stackoverflow.com/questions/13653712/java-sql-sqlexception-incorrect-string-value-xf0-x9f-x91-xbd-xf0-x9fhttp://afei2.sinaapp.com? P = 518 & utm_source = tuicool & utm_medium = referralhttp: // reset (replacement method)

Copy a command

alter table foo.foo convert to character set utf8mb4 collate utf8mb4_unicode_ci

Then the Java code must declare this:

SET NAMES 'utf8mb4'

To insert an Emoji.

Mysql Configuration

[client]default-character-set = utf8mb4[mysqld]character-set-server=utf8mb4collation-server=utf8mb4_unicode_ci[mysql]default-character-set = utf8mb4

In addition, upgrade the JDBC driver.

Test the code. You can also check whether your browser correctly displays the Emoji expression (it cannot be a question mark or square. Upgrade your browser !).

Oh mygod, CSDN database plug-in! It will be interrupted if you encounter the Emoji character! I still need to use images.

Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. PreparedStatement;
Import java. SQL. ResultSet;

Public class Test {

Public static void main (String [] args ){
System. out. println ("test string =" +"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.