The way to modify the character set is to use the MySQL command mysql> SET character_set_client = UTF8; mysql> SET character_set_connection = UTF8; use mysql> show VARIABLES like ' character% '; view, discover that database encoding has been changed to UTF8
+--------------------------+---------------------------------+ | variable_name | & #118alue |
+--------------------------+---------------------------------+ | 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 | D: "mysql-5.0.37" Share "charsets" | +
--------------------------+---------------------------------+
mysql> SHOW VARIABLES like ' collation_% ';
+----------------------+-----------------+
| variable_name | & #118alue |
+----------------------+-----------------+
| collation_connection | Utf8_general_ci |
| Collation_database | Utf8_general_ci |
| Collation_server | Utf8_general_ci |
+----------------------+-----------------
or open the MySQL installation directory, there is a My.ini file, open this file, there are two character set settings, the default is Latin, it is recommended that you want to change, such as: UTF8 or GBK and then start the MySQL service, the default character set of the database created later is OK (restart, Open the Mysqladministrator service control to do it. )
Some other ways to modify MySQL encoding:
1. If the installation of MySQL code can not be changed, many friends are buying a virtual host to build a website, do not have the right to change the installation code of MySQL, this level we can skip, because as long as the following step together correctly, as can solve the garbled problem
2. Modify the database encoding, if the database encoding is incorrect: You can execute the following command in phpMyAdmin: ALTER database ' test ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin the above command is to set the test database encoding to UTF8
3. Modify the table's encoding: ALTER table ' category ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin The above command is to change the encoding of a table category to UTF8
4. Modify the encoding of the field: ALTER TABLE ' test ' change ' dd ' "dd ' VARCHAR" CHARACTER SET UTF8 COLLATE utf8_bin not NULL The above command is to change the field encoding of DD in the test table to UTF8
Technology sharing: Edith Academy
This article from the "11247808" blog, reproduced please contact the author!
Modify the encoding format MySQL