Why do you want to set the database charset to UTF8MB4? UTF8 used to be all the time?
The answer is here: UTF8 for Internet interactions that do not use mobile devices, UTF8MB4 is suitable for the current mobile device Internet development, as mobile devices often have emoji (emoji) storage, which consumes 4 bytes of storage space, while UTF8 is 3 bytes, so that With 3 bytes to store 4 bytes of things, it is obvious that there is no way, will error, so to use UTF8MB4, and UTF8MB4 is compatible with UTF8, then there is no reason not to use UTF8MB4 character set.
Describes setting the character set for MySQL:
1 Install MySQL in ubuntu (password own settings)
sudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt- Get Install Libmysqlclient-dev
2 accessing MySQL, viewing information
/etc/mysql/mysql.conf.d/mysqld.cnf
Can see my MySQL version is 5.7, UTF8MB4 has a use limit, MySQL version must be more than 5.5, we need to note that I currently use the Ubuntu system is 16.04. The current MySQL character set is configured as in the table above, and our aim is to change to UTF8MB4.
3 MySQL configuration file found, available commands
sudo find/-name my.cnf
4 Modifying a 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 '
or direct execution:
ALTER Table Apps modify name varchar (character) set UTF8MB4 collate utf8mb4_unicode_ci;
ALTER table Apps charset=utf8mb4;
Set Names UTF8MB4
MySQL: Setting character set UTF8MB4 supports emoji characters