How to avoidMySQLGarbled
To avoid garbled characters when the MySQL content in the database is displayed on the webpage, you can use the following methods to check and change the character set in MySQL ).
CheckMySQLText code settings in
In the MySQL environment, enter the following MySQL command to view the current characterset status. We can see that the default value of each text code is "lanten1 」.
Mysql> showvariables like 'character _ set % ';
Or
Mysql> status;
When creating a new database, you can use the following MySQL commands to set and confirm the preset text code of the database. For example, the default text code for the database of "mydb" is set to the ten-dollar code of "UTF-8.
Mysql> createdatabaase mydb default Character Set utf8;
Mysql> showcreate database mydb;
Edit/Etc/My. CNFFiles
Edit the character set in the/etc/My. CNF file and save it. For example, the text code is set to a-digit "UTF-8.
[Client]
Default-character-set = utf8
[Mysqld]
Default-character-set = utf8
Skip-character-set-client-handshake
Character-set-Server = utf8
Collation-Server =
Utf8_general_ci
Init-connect = set names utf8
In the configuration file, "Skip-character-set-client-handshake" is added to prevent internal MySQL transformation.
Manual restartMySQL
After the configuration is complete, manually stop and enable the MySQL service.
Stop Services manually
#/Usr/local/MySQL/bin/mysqladmin Shutdown
Manually enable the Service
#/Usr/local/MySQL/bin/mysqld_safe -- user = MySQL &
Finally confirm the set result, if all the set text code is changed to "UTF-8" ten thousand code, indicates that the set is complete.
Mysql> showvariables like 'character _ set % ';
Or
Mysql> status;
ByWww.435dns.comSort and post, reprinted please note