MySQL is a commonly used open source database software, but it does not seem to be very friendly to first-time users. The default character set in MySQL5.x version is latin1, which is the ISO-8859-1 character set we know. This character set encoding does not include Chinese characters, so when we use it, Chinese characters will appear garbled. This can be solved by modifying the database default character set. Enter the MySQL command line: mysql> show variables like '%colla%'; +----------------------+-------------------+ | Variable_name | Value | +----------------------+-------------------+ | collation_connection | gbk_chinese_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+ 3 rows in set, 1 warning (0.00 sec) mysql> show variables like '%char%'; +--------------------------+---------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.7\share\charsets\ | +--------------------------+---------------------------------------------------------+ 8 rows in set, 1 warning (0.00 sec) You can see that the default character set is now latin1 Find the MySQL configuration file. The configuration file in Windows is my.ini. My computer is located at C:\ProgramData\MySQL\MySQL Server 5.7. The file that needs to be modified in Linux is my.conf. The specific path depends on your actual installation location. Modify the configuration in the following nodes respectively: The configuration of the [client] node in the 5.7 I use needs to be added, and the other two nodes [mysql] and [mysql] need to open the comments and change them to utf8. [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysql] character_set_server=utf8 Then restart MySQL
Check the character set again, all have been changed to utf8 character set mysql> show variables like '%colla%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | gbk_chinese_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+ 3 rows in set, 1 warning (0.00 sec) mysql> show variables like '%char%'; +--------------------------+---------------------------------------------------------+ | 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.7\share\charsets\ | +--------------------------+---------------------------------------------------------+ 8 rows in set, 1 warning (0.00 sec) To ensure encoding consistency, you can also specify the character set when creating a database or table, and specify the connection parameters after the connection string: ?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue implements the sample code of adding, deleting, modifying and checking the tree structure
>>: Detailed explanation of Docker Swarm concepts and usage
Table of contents Preface Mixin Mixin Note (dupli...
Need to know how many days there are before an im...
Sttty is a common command for changing and printi...
MouseEvent When the mouse performs a certain oper...
1. Prerequisites We use the require.context metho...
To create a flex container, simply add a display:...
We often need to control the hidden, transparent ...
Preface This article mainly introduces the releva...
MySQL trigger simple example grammar CREATE TRIGG...
npm uninstall sudo npm uninstall npm -g If you en...
I have been working on a project recently - Budou...
Today I suddenly thought of reviewing the producti...
MySQL password modification example detailed expl...
Configuration Preface Project construction: built...
Table of contents need: Problems encountered: sol...