Linux modify mysql character set encoding

Summary: This article applies to mysql5.5 mysql5.6 other versions have not tested mysql -u account -p password to log in to mysql mysql>SHOW VARIABLES LIKE 'character%'; View the current character set encoding method MySQL [(none)]> SHOW VARIABLES LIKE 'cha

This article applies to mysql5.5 mysql5.6 other versions have not tested

mysql -u account -p password Log in to mysql
mysql>SHOW VARIABLES LIKE 'character%'; View the current character set encoding method

MySQL [(none)]> SHOW VARIABLES LIKE 'character%';
+--------------------------+----------------- -----------------+
| Variable_name | Value |
+-------------------------------------- +-----------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+------------------------ --+---------------------------------+
8 rows in set (0.01 sec)

here is gbk , now change to utf8, and vice versa
Edit /etc/my.cnf file
Add default-character-set = utf8 under the [client] field
Add character-set-server = utf8 under the [mysqld] field Add character-set-server = utf8
under the [mysql] field Add default-character-set = utf8

Note: After adding this paragraph in the mysql field, I found that mysql restarted and reported an error, so I removed this paragraph, and mysql was normal, but then I continued to try again, and no error was reported, I don’t know what is the problem.

After the modification is completed, the mysql service needs to be restarted!
Then log in to mysql at #mysql -u account -p password
mysql>SHOW VARIABLES LIKE 'character%';

MySQL [(none)]> SHOW VARIABLES LIKE 'character%';
+--------------------------+---------------------- ------------+
| 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 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+------------------- --------+------------------------------------------------+
8 rows in set (0.01 sec)

At this time, the database code is changed to utf8


and the Yunqi Community APP is used, which is comfortable~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326218622&siteId=291194637