mysql set character set

The problem of garbled characters has always been one of the most annoying problems for programmers. Today, I checked some information on the Internet and summarized the character encoding settings of mysql as follows.
      One: First, modify the configuration file my.ini
           in mysql, and modify it in the [mysql] tag default-character-set=utf8 Add default-character-set=utf8
          in the [client] tag
          Modify default-character-set=utf8
          in the [mysqld] tag Add character_set_server = utf8 in the [mysqld] tag #Table
                            names are indistinguishable case (this has nothing to do with encoding)
                                 lower_case_table_names = 1 
          add labels [mysql.server] and [mysql_safe] and add
          default-character-set=utf8 
      command line input net stop mysql
      command line input net start mysql
      command line input under the label respectively mysql -uroot -pXXX Enter the
       command line and enter show variables like 'character\_set\_%'; [for viewing the mysql encoding method]
+--------------------------+--------+
| Variable_name | Value |
+------- -------------------+--------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
+--------------------------+-------- +
Shows all encodings;
you can also modify the encoding of the database
Command line input alter database test character set 'gbk';
+-------------------- ------+-------+
| Variable_name | Value |
+--------------------------------------+- -------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
|
------------+--------+
This sets the encoding method of the table in the test database to GBK.
If you want to change character_set_filesystem to utf8;
enter set character_set_filesystem on the command line =utf8;
command line input set character_set_database=utf8;
command line input show variables set 'character\_set\_%';
+------------- ---+-------+
| Variable_name | Value |
+--------------------------+----- --+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
|
------------+-------+ But the encoding of character_set_filesystem is still +---------------
after the next startup
-------------+--------+
| Variable_name | Value |
+------------- ---+--------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
+--------------------------+------- -+
Because character_set_client and character_set_filesystem have been set in the configuration file, the modification here is only valid for the current page.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326883320&siteId=291194637