Command: echo $LANG
[root@pythontab.com ~]# echo $LANG
[root@pythontab .com ~]# en_US.UTF-8
Check whether it is en_US. If not, you can modify it as follows:
1. Modify it by directly setting the variable. The following two commands Command:
[root@pythontab.com ~]# export LANG=en_US.UTF-8;
[root@pythontab.com ~]# export LC_ALL=en_US.UTF-8;
2. Modify the file method and control it by modifying the /etc/sysconfig/i18n file
[root@pythontab.com ~]# vim /etc/sysconfig/i18n
LANG="en_US.UTF-8" #It is the language of the system, you can modify this item
For the modified file to take effect after saving and exiting, you must execute the following command to take effect
[root@ pythontab.com ~]$ source /etc/sysconfig/i18n
Note: The above en_US.UTF-8 is the configuration of my server. If yours is en_US, it doesn’t matter. No It affects subsequent operations and does not affect the normal display of Chinese.
The default character encoding setting of the ssh client is default. As long as it is changed to specify UTF-8, Chinese can be displayed on the terminal.
What this means is that Chinese in general files can be displayed normally, but Chinese in mysql is not necessarily displayed normally. If it is not displayed normally, please continue reading and follow the steps below.
SecureCRT settings: (You can directly set the session selection after opening the session) Options->Session Options->Appearance->Character encoding, Select UTF-8.
This sets the default display character set.
Check the mysql server character set system variables:
mysql>show variables like 'character_%';
mysql>show variables like 'collation%';
The character set of the final client connection is specified by the client when connecting
Specify the character set command when connecting:
mysql --default-character-set=utf8
If you don’t want to specify the connection character set every time you connect to the database, you need to specify the character set in the configuration file, but after changing the configuration file, you need to restart the service for it to take effect.
Edit /etc/my.cnf and modify the following configuration items
[client]
set character_set_results=utf8
[mysql]
set character_set_results=utf8
Summary: If you want the ssh client (SecureCRT, etc.) to display mysql Chinese without garbled characters, you must ensure the Linux system character set, the ssh client display character set, and the mysql client The character set of end-to-end connections is the same!
The above is the detailed content of Solving Chinese garbled characters in MySQL under SecureCRT. For more information, please follow other related articles on the PHP Chinese website!