PHP. ini default_charset = "UTF-8"
Header ('content-type: text/html; charset: UTF-8 ');
<
Virtualhost
*: 80>
DocumentRoot "/var/www/html /"
Servername 111.com.tw
Adddefacharcharset UTF-8
<
Directory
"/Var/www/html/">
This part is reproduced and hereby declares
MySQL Character Set Problems
MySQL character set support has two aspects:
Character Set and collation ).
The support for character sets is refined to four layers:
Server, database, table, and connection ).
1. Default MySQL Character Set
MySQL can refine the character set designation to a database, a table, and a column.
However, traditional programs do not use such complex configurations when creating databases and data tables. They use the default configuration. So where does the default configuration come from?
(1) When compiling MySQL, a default character set is specified, which is Latin1;
(2) When installing MySQL, you can specify a default character set in the configuration file (My. conf). If this character set is not specified, this value inherits from the one specified during compilation;
(3) When mysqld is started, you can specify a default character set in the command line parameters. If not, this value inherits from the configuration in the configuration file, character_set_server is set to the default character set;
(4) When creating a new database, unless explicitly specified, the character set of this database is set to character_set_server by default;
(5) When a database is selected, character_set_database is set to the default Character Set of the database;
(6) When creating a table in the database, the default Character Set of the table is set to character_set_database, which is the default Character Set of the database;
(7) When setting a column in a table, unless explicitly specified, the default character set in this column is the default Character Set of the table;
How to modify the MySQL character set:
- Modify the/etc/My. conf file
[Mysqld]
Default-character-set = utf8
Default-collation = utf8_general_ci
Character-set-Server = utf8
Collation-Server = utf8_general_ci
Init-connect = 'set names utf8'
[Client]
Default-character-set = utf8
The red part is the newly added content.
Restart service mysqld restart
2. method 1 modification is invalid for an existing table
Alter table review convert to Character Set utf8; test the validity of an existing table in MySQL database
How to view the MySQL Character Set
Show variables like 'collation % ';
Show variables like 'character % ';