1. First introduce the following commonly used character sets
- ASCII: United States Information Interchange standard coding; English and other Western European languages; single-byte encoding, 7-bit represents a character, a total of 128 characters.
- GBK: Double-byte, Chinese character code expansion specification; Chinese, Japanese and Korean characters, English, numerals, double-byte encoding, a total of 21,003 Chinese characters, GB2312 extension.
- Utf-8:unicode standard variable length character encoding, Unicode Standard (Uniform code), industry uniform standards, including the world's dozens of kinds of text system;
- UTF-8: Encode each character using one to three bytes.
- Utf8mb4: Stores four bytes, and the scenario is used to store the emoji expression because it can emoji four bytes of expression.
- Utf8mb4:mysql versions > 5.5.3.
- Other common character sets: Utf-32,utf-16,big5,latin1
2. Modify the Local database
for each of the databases:
ALTER database is here the name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
For each of the tables:
ALTER table here is the table name CONVERT to CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
3. Modify the MySQL configuration file
Go to this directory, under this directory there is a suffix .cnf
file
cd/usr/local/mysql/support-files/
Copy this file to the etc
directory and name my.cnf
it
sudo cp my-default.cnf/etc/my.cnf
Then edit the my.cnf
file and copy the contents below.
[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
4. Restart MySQL
- Start:/usr/local/mysql/support-files/mysql.server start
- Stop:/usr/local/mysql/support-files/mysql.server stop
- Restart:/usr/local/mysql/support-files/mysql.server restart
Service Mysqld Stop
Service mysqld Start
Service mysqld Restart
Make Mac version of MySQL support emoji emoticons