1) as long as it is gb2312, GBK, utf8, and other character sets that support multi-byte encoding, you can store Chinese characters. Of course, the number of Chinese Characters in gb2312 is much smaller than that in GBK, while in gb2312, GBK and so on can all be encoded in utf8.
2) run the show variables like 'character \ _ set \ _ % 'command to view the current character set settings:
Mysql> show variables like 'character \ _ set \ _ % ';
+ -------------------------- + -------- +
| Variable_name | value |
+ -------------------------- + -------- +
| Character_set_client | gb2312 |
| Character_set_connection | gb2312 |
| Character_set_database | gb2312 |
| Character_set_filesystem | binary |
| Character_set_results | gb2312 |
| Character_set_server | Latin1 |
| Character_set_system | utf8 |
+ -------------------------- + -------- +
7 rows in SET (0.02 Sec)
(The character I set here is gb2312)
There are two main settings for displaying Chinese garbled characters: character_set_connection and character_set_results,
If your two settings do not support Chinese encoding, garbled characters will appear. If: Set character_set_results = GBK;, the Chinese encoding will be set.
3). Set names charset_name; you can also set all character sets of the client at one time.
In. NET and MySQL databases, I also encountered a situation where Chinese characters could not be displayed!
My solution is to add a character set charset = utf8 to the connection character;
<Deleetask>
<Add key = "conn" value = "Server = 127.0.0.1; userid = root; Password = test; database = game; Port = 3306; charset = utf8;"/>
</Appsettings>
If UTF-8 encoding is used in Python
When creating data, you must add the default Character Set utf8 collate utf8_general_ci
Otherwise, a message such as data too long for column is displayed when you enter Chinese characters!
Create Database test default Character Set utf8 collate utf8_general_ci
MySQL authorized remote host:
Grant all privileges on *. * to identified by 'mypassword' with grant option;
If you want to allow myuser to connect to the MySQL server from a host whose IP address is 192.168.1.3, and use mypassword as the password:
Grant all privileges on *. * to identified by 'mypassword' with grant option;