MySQL sets the default database Encoding
If the encoding method is not selected during MySQL installation, the system selects latin1 encoding by default, in the MySQL Console window, enter show variables like 'Char % 'to view the default sequence set of the database system, as shown below:
We can see that the default encoding of the system is Latin1 encoding method, Latin1 is the alias of the ISO-8859-1, some environments write Latin-1. ISO-8859-1 encoding is a single-byte encoding that is backward compatible with ASCII. Chinese encoding is not supported. If you do not specify the encoding method when creating a database or table, the database uses the default encoding method, then, garbled characters will appear when you insert Chinese data. But if we need to manually specify the encoding method every time we create a database or a key table, it will be very troublesome. How can we manually modify the default encoding method of the database?
1. Close the mysql service, manually stop the mysql service in the service, or enter net stop mysql in the cmd window.
2. find my. INI file, if it is for the database initialization, then change the my-default.cof to my. cof, find [mysql] in the file, and add the following two lines to the next line.
Character_set_server = gbk
Init_connect = 'set NAMES gbk'
You can also directly add it to my. ini.
As follows:
3. Save and restart. Check again. We can see that the default encoding of the system has changed.
This article permanently updates the link address: