After reloading the system, to install a MySQL server, found to add data, has been wrong, check its cause, the original encoding problem. Google a bit, but it is not the same, maybe the database version of the problem it.
To view the database version:
Select version ();
Show: ' 5.7.15-0ubuntu0.16.04.1 '
Official Documentation: Mysql document
1. View Database encoding
like ' character% ';
Show Results:
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/ |
Character_set_client for the client code, character_set_connection for the establishment of the connection using the encoding; character_set_database database encoding; character_set_ Results the encoding of the result set; the encoding of the Character_set_server database server;
As long as the above four is guaranteed to use the same encoding method, there will be no garbled problem.
2. Set the database encoding
Divided into two parts: setting the database server encoding and setting the database encoding
Setting the database encoding is simple, when you create a database, you can specify the encoding;
If you set the server encoding, you need to modify the configuration file. The configuration file path is:/ETC/MYSQL/MYSQL.CONF.D
Locate [mysqld], and after adding the following code, restart the server.
character - Set -Server=utf8collation-Server=utf8_general_ci
3. Restart the database
Service MySQL Restart
Linux set MySQL database encoding