Solving Chinese garbled characters in MySQL under SecureCRT

巴扎黑
Release: 2017-08-22 13:24:55
Original
2523 people have browsed it

1. Check the Linux host system character set

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.

2. Change the default display character set of the ssh client

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.

3. Check the character set settings of mysql

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template