From the front-end inserted in Chinese, to the background MySQL view is a question mark.
Can not be displayed in Chinese, the initial decision is the problem of coding.
We use
Show variables like ' character_set_% ';
And
Show variables like ' collation_% ';
This command checks to see if the MySQL encoding format is the following
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/local/mysql-5.7.16-osx10.11-x86_64/share/charsets/|
+--------------------------+---------------------------------------------------------+
And
Show variables like ' collation_% ';
+----------------------+-----------------+
| variable_name | Value |
+----------------------+-----------------+
| collation_connection | Utf8_general_ci |
| Collation_database | Utf8_general_ci |
| Collation_server | Utf8_general_ci |
+----------------------+-----------------+
After 5.5 MySQL Most people's default configuration should be the same as most of the above, except for the following 2
Character_set_database | Latin1
Character_set_server | Latin1
and Collation_database and Collation_server are different.
The two tables shown above are the result of a modification, so how to modify them.
There are no my.cnf and my-medium.cnf files after 5.5.
There is a my-default.cnf file under the Support-files file.
Do the following. (Close the database and disconnect the database service before you do the following)
sudo cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
sudo vi/etc/my.cnf
After opening my.cnf, add the following two lines of settings under [mysqld] within the file:
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 ' save exit
Start the database service from the beginning, open the database, view the encoding format, and discover that it has changed
It is important to note that the encoding format of the table created by default is not changed! So, if you want to make a table that is created before you modify the encoding format, it also modifies
Please follow the instructions below
1. Modify the encoding format of the database
Mysql>alter databases < database name > character set UTF8;
2. Modify the data table encoding format
Mysql>alter Table < name > character set UTF8;
3. Modify the field encoding format
Mysql>alter Table < name > Change < Field name > < Field name > < type > Character set utf8;mysql>alter table user Cha Nge username username varchar (character set UTF8 not null;
The modified database and the tables in the library do not make the original data effective, but the newly added data will not take effect.
MySQL Chinese display question mark, do not recognize the solution of Chinese