SQLyog v11.24: How to query Chinese garbled characters in MySQL5.6.24 sqlyogmysql5.6.24
After searching for this problem online for half a day, I did not find a solution. Finally, I used a small skill to solve it myself.
Reprinted please indicate the source:
Http://blog.csdn.net/ouyida3/article/details/46606689
This article is from: [ouyida3 blog]
Solution: run the following command:
SET character_set_results = gbK;
For details, refer:
Baidu Zhili's answer
In this answer,
SET character_set_client = gbK; SET character_set_results = gbK; SET character_set_connection = utf8;
Or
SET character_set_client = utf8;SET character_set_results = gb2312;SET character_set_connection = utf8;
All of them can be tried. However, I only need to set results to gbk. In addition, the settings Font mentioned in the second part do not exist in my new version.
This setting is indeed not garbled, but restarting SQLyog does not take effect.
On the Internet, set the character-set-server parameter or default parameter in the my. cnf configuration file on the server. I have set gbk on my server.
[aipaas@aipaas03 /app]$more my.cnf[mysqld_multi]mysqld = /app/mysql/bin/mysqld_safemysqladmin = /app/mysql/bin/mysqladminuser = mysqlpassword = aiLk@Aug[mysqld020]port = 3020socket = /tmp/mysql.sock01pid-file = /app/data_01/db-app.pidbasedir = /app/mysqldatadir = /app/data_01user = mysqlsymbolic-links=0character-set-server=gbkndbclusterndb-connectstring=130.51.23.24explicit_defaults_for_timestampoptimizer_switch=engine_condition_pushdown=off
The character set is correct when I use the mysql client COMMAND LINE ON THE HOST:
MySQL [portaldb]> SHOW VARIABLES LIKE 'char%' -> ;+--------------------------+--------------------------------------------------------------------+| Variable_name | Value |+--------------------------+--------------------------------------------------------------------+| character_set_client | gbk || character_set_connection | gbk || character_set_database | gbk || character_set_filesystem | binary || character_set_results | gbk || character_set_server | gbk || character_set_system | utf8 || character_sets_dir | /app/mysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64/share/charsets/ |+--------------------------+--------------------------------------------------------------------+8 rows in set (0.00 sec)
This indicates that different clients may generate different character sets on the same server, because I think there should be methods to modify character sets on the client.
The character set of sqlyog (which is significantly different from the preceding command line client ):
At this time, the DBA of the company asked me to use gbk when creating a table. I think it is unreliable. First of all, why does the table have to be created in gbk? Second, I have no garbled characters in the command line, but garbled characters in SQLyog. I don't think it is a problem to create a table character set.
SHOW CREATE TABLE sys_config;Table Create Table ---------- --------------sys_config CREATE TABLE `sys_config` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type_code` varchar(30) COLLATE utf8_bin DEFAULT NULL, `param_code` varchar(30) COLLATE utf8_bin DEFAULT NULL, `service_value` varchar(20) COLLATE utf8_bin DEFAULT NULL, `service_option` varchar(255) COLLATE utf8_bin DEFAULT NULL, `descb` varchar(255) COLLATE utf8_bin DEFAULT NULL, `state` varchar(2) COLLATE utf8_bin DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
As long as you log on to the database, you can execute this command by default:
The problem is solved perfectly.
My Reference Links:
- About how MySQL modifies character_set_client Encoding
- Http://blog.csdn.net/ACMAIN_CHM/article/details/4174186
- Http://www.itpub.net/thread-1806655-1-1.html
2015.6.23