Solve the Chinese garbled code problem of mysql5.5 database command line under Windows10

  • 2021-08-31 09:33:47
  • OfStack

After resetting the system, the MySQL database installed a long time ago appeared the problem of console query Chinese garbled code, and it took too long to remember how to set it up.

I inquired a lot on the Internet, and all kinds of settings were still garbled in Chinese after restarting the database.

It may be that my search method is wrong, and finally it has been solved. I specially opened 1 virgin blog record 1 time:

Open the my. ini file in the installation directory

Mine is: C:\ Program Files\ MySQL\ MySQL Server 5.5 Below, modified as follows:

# This one below the Internet  gbk  Many answers are also set to utf8 The result is garbled code 
# ----------------------------------------------------------------------
## The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
[mysqld]# The TCP/IP Port the MySQL Server will listen on
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
 Restart after modification mysql , view 1 Lower code: 
mysql> show variables like 'character_set%';
Variable_name | Value |
 character_set_client | gbk || 
character_set_connection | gbk ||
 character_set_database | utf8 || 
character_set_filesystem | binary || 
character_set_results | gbk || 
character_set_server | utf8 ||
 character_set_system | utf8 ||
 character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
 Try operation: 
mysql> insert into per values(' Garbled code resolution ');
Query OK, 1 row affected (0.00 sec)
mysql> select * from per;
name |
 From one after another  ||
  Garbled code resolution  |
3 rows in set (0.00 sec)


Related articles: