The following articles mainly introduce the practical application of the MySQL Character Set, including how to correctly configure the default Character Set of the MySQL database and how to view the MySQL database character set currently used by the database? 1. Configure the MySQL Default Character Set [client] default-character-setutf8 client Connection
The following articles mainly introduce the practical application of the MySQL Character Set, including how to correctly configure the default Character Set of the MySQL database and how to view the MySQL database character set currently used by the database? The following describes the main content of the article. 1. Configure the MySQL default character set [client] default-character-set = utf8 client Connection
The following articles mainly introduce the practical application of the MySQL Character Set, including how to correctly configure the default Character Set of the MySQL database and how to view the MySQL database character set currently used by the database? The following describes the main content of the article,
1. Configure the MySQL Default Character Set
- [client]
- default-character-set=utf8
Default MySQL character set for client connection
- [MySQLd]
- default-character-set=utf8
MySQLd default Character Set
2. view the MySQL character set currently used by MySQL
- MySQL> 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/MySQL/charsets/ |
- +--------------------------+----------------------------------------+
Use the MySQL command to modify the MySQL Character Set
- MySQL> SET character_set_client = utf8 ;
- MySQL> SET character_set_connection = utf8 ;
- MySQL> SET character_set_database = utf8 ;
- MySQL> SET character_set_results = utf8 ;
- MySQL> SET character_set_server = utf8 ;
3. C api
- MySQL_options(MySQL, MySQL_SET_CHARSET_NAME, 'utf8');
- MySQL_real_connect(MySQL, ...);
In most cases, using the default MySQL code latin1 can solve the MySQL garbled problem. During data insertion and reading, you do not need to use MySQL_options to specify the encoding type. The configuration file my. cnf does not need to specify the encoding type.