MySQL store emoji emoticons to use the UTF8MB4 character set, which is 4 bytes of storage, the minimum supported version is 5.5.3+, if not, upgrade to a newer version.
Modify the MySQL configuration file
Window directory: mysql/my.iniubuntu16.04 directory:/ETC/MYSQL/CONF.D/MYSQL.CNF configuration client/etc/mysql/mysql.conf.d/mysql.cnf Configure server Other directories: generally in ETC/MYSQL/MY.CNF
Add the following three parts to the MySQL configuration file:
[Client]default-character-set = Utf8mb4[mysql]default-character-set = Utf8mb4[mysqld] Character-set-client-handshake = Falsecharacter-set-server = Utf8mb4collation-server = Utf8mb4_unicode_ciinit_ connect= ' SET NAMES utf8mb4 '
Restart MySQL after modifying, check the character set
# mysql-uroot-p# mysql > SHOW VARIABLES WHERE variable_name like ' character_set_% ' OR variable_name like ' collation% ' ;
Results
+--------------------------+--------------------+| variable_name | Value |+--------------------------+--------------------+| character_set_client | utf8mb4 || character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | collation_connection | utf8mb4_unicode_ci | | collation_database | utf8mb4_unicode_ci | | collation_server | utf8mb4_unicode_ci |+- -------------------------+--------------------+rows in set (0.00 sec)
Java Link Configuration
jdbc.driverclass=com.mysql.jdbc.driverjdbc.jdbcurl=jdbc:mysql://localhost:3306/tgb?useunicode=true& characterencoding=utf8&autoreconnect=true&rewritebatchedstatements=truejdbc.user=rootjdbc.password= Jdbc.initialpoolsize=10jdbc.minpoolsize=10jdbc.maxpoolsize=50jdbc.maxidletime= 3600jdbc.testconnectiononcheckout=falsejdbc.testconnectiononcheckin=truejdbc.idleconnectiontestperiod=3600
This article is from the "Yang Chongxin blog" blog, make sure to keep this source http://yangchongxing.blog.51cto.com/1004067/1969794
Java stores emoji emoticons in MySQL