First, login MySQL view with show VARIABLES like ' character% '; The following character set, shown below:
+--------------------------+----------------------------+| variable_name | Value |+--------------------------+----------------------------+| character_set_client | UTF8 | | character_set_connection | UTF8 | | Character_set_database | Latin1 | | Character_set_filesystem | binary | | Character_set_results | UTF8 | | Character_set_server | Latin1 | | Character_set_system | UTF8 | | Character_sets_dir | /usr/share/mysql/charsets/|+--------------------------+----------------------------+
The default character set for Character_set_database and Character_set_server is still latin1.
Second, the simplest perfect modification method, modify the MySQL my.cnf file character Set key value (note the configuration of the field details):
1, add default-character-in the [Client] fieldSet=UTF8, as follows: [Client]port=3306Socket= /var/lib/mysql/Mysql.sockdefault-character-Set=UTF82, add character-in the [mysqld] fieldSet-server=UTF8, as follows: [Mysqld]port=3306Socket= /var/lib/mysql/Mysql.sockcharacter-Set-server=UTF83, add default-character-in the [MySQL] fieldSet=UTF8, as follows: [MySQL] #no-auto-Rehashdefault-character-Set=utf8
After the modification is complete, service MySQL restart restart the MySQL services to take effect. Note: The [mysqld] field differs from the [MySQL] field.
Restart the MySQL service.
sudo service MySQL start
Use show VARIABLES like ' character% '; view, found that the database encoding has been changed to UTF8.
+--------------------------+----------------------------+| variable_name | Value |+--------------------------+----------------------------+| character_set_client | UTF8 | | character_set_connection | UTF8 | | Character_set_database | UTF8 | | Character_set_filesystem | binary | | Character_set_results | UTF8 | | Character_set_server | UTF8 | | Character_set_system | UTF8 | | Character_sets_dir | /usr/share/mysql/charsets/|+--------------------------+----------------------------+
The modified character set encoding for Linux under MySQL5.6 is UTF8