After installing mysql, start the service and log on to the mysql database. Run the showvariables command to view the default encoding of the mysql database. The default encoding of the mysql database is not modified by UTF-8. This article will introduce in detail, interested friends can learn more
After installing mysql, start the service and log on to the mysql database. Run the show variables command to view the default encoding of the mysql database. The default encoding of the mysql database is not modified by UTF-8. This article will introduce in detail, interested friends can learn more
The default encoding of the mysql database is not UTF-8.
After installing mysql, start the service and log on to the mysql database. Run the show variables command to view the default encoding of the mysql database:
The character set of the visible database and server uses the latin1 encoding mode. Chinese characters are not supported, that is, garbled characters appear when storing Chinese characters. The following is the process of modifying the command line to UTF-8 encoding to support Chinese characters.
(1) disable the mysql Service
The Code is as follows:
Service mysql stop
(2) Modify/etc/mysql/my. cnf (default installation path)
The Code is as follows:
Vim/etc/mysql/my. cnf
After opening my. cnf, add the following two lines under [mysqld] in the file:
The Code is as follows:
Character_set_server = utf8
Init_connect = 'set NAMES utf8'
(As shown in ):
Save and exit.
(3) restart the mysql Service
The Code is as follows:
Service mysql start
Now, the default encoding is modified. log on to mysql and use show variable like '% character %' again to obtain the following output:
Note
The specific operations and output are as follows: