System environment: CentOS Linux release 7.4.1708 (Core)
MySQL version: 5.6.11
Scenario: Newly installed database, create database, create data table, insert Chinese data error
resolution process:
1, modify the configuration file my.cnf add the following three
= Utf8[mysql]default-character-set=utf8[client]default-character-set=utf8
2. Restart the database, and at the command line, see if the character set changes to UTF8
3. The database and data tables created by the original must change the character set1) database change character Set
ALTER DATABASE database_name default character set UTF8;
2) View database information
Show CREATE DATABASE database_name;
3) data table change Character set
ALTER TABLE table_name default character set UTF8;
4) View Create data table information
Show CREATE TABLE student_message;
4, so far, insert Chinese characters will be error, because the data table column character set does not change1) You have to change the character set of the column.
Char (ten) character set UTF8
2) After all changes, can be inserted successfully
Summary: That is, from the library to the table, the character set from the table to the column has to be changed.
MySQL Character set