The default encoding in mysql is latin1 (ISO_8859_1), which can be viewed using the "SHOW VARIABLES LIKE 'character%';" command. latin1 encoding is a single-byte encoding, backward compatible with ASCII, but does not support Chinese. You can modify the default encoding by searching and setting the values of the "default-character-set" and "character_set_server" items in the configuration file "my.ini" .
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
MySQL default character set
MySQL’s character set specification can be refined to a database, a table, and a column. What character set should be used. However, traditional programs do not use such complex configurations when creating databases and data tables. They use default configurations. So, where does the default configuration come from?
When compiling MySQL, a default character set is specified, which is latin1;
By default, the character set of mysql is latin1 (ISO_8859_1).
ISO-8859-1 encoding is a single-byte encoding and is backward compatible with ASCII. Chinese encoding is not supported. If you do not explicitly specify the encoding method when creating a database or table, the database will use the default encoding method, and then when you insert Chinese data, garbled characters will appear
How to check the default character set
Usually, you can use the following two commands to check the system character set and sorting settings:
SHOW VARIABLES LIKE 'character%';
SHOW VARIABLES LIKE 'collation_%';
#Modify the method of modifying the default character set
The default encoding of MySQL is Latin1, which does not support Chinese, so how to modify MySQL The default encoding of client] and [mysqld], add
default-character-set=utf8, save and close (if an error occurs after adding in mysqld, you can try
character-set-server=utf8)default-character-set = utf8 character_set_server = utf8
[Related recommendations: mysql video tutorial
]
The above is the detailed content of What is the default encoding of mysql. For more information, please follow other related articles on the PHP Chinese website!