A table when the display of normal Chinese, the establishment of the table after the query is garbled.
Mysql> Show tables;+----------------+| Tables_in_test |+----------------+|????? || Table1 |+----------------+2 rows in Set (0.00 sec)
This typically occurs because of inconsistent encoding types on the client and server side.
View some of the encoding types on the client and server side:
mysql> show variables like "%char%"; +--------------------------+----------- -----------------+| variable_name | value |+--------------------------+----------------------------+| character _set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ |+--- -----------------------+----------------------------+8 rows in set (0.00 sec) MySQL >
It can be seen from the server is UTF8, and the client is Latin, temporarily set the client code:
SET character_set_client= ' UTF8 '; SET character_set_connection= ' UTF8 '; SET character_set_results= ' UTF8 ';
Check again to see if the table is garbled:
Mysql> Show tables; +-----------------+| Tables_in_test |+-----------------+| Student Information Sheet | | Table1 |+-----------------+2 rows in Set (0.00 sec)
This is the result of inconsistent coding, resolved:
1. If the database encoding inconsistency causes garbled characters, you need to modify the encoding type of the database:
Show CREATE database test;alter database test character set UTF8 COLLATE utf8_general_ci;
2. If this is a client problem, edit the configuration file and add the following line:
[Client]default-character-set=utf8
This article from "Small East elder brother" blog, declined reprint!
MySQL Query when garbled solution