Several people have raised garbled questions, and many others have asked related questions. I have also been confused. Today I understand that the latter is a few simple words.
First, check the Chinese garbled characters in the MySQL database?
In case of chaos, first configure the/etc/My. CNF file and rewrite the mysqld and client character sets to UTF-8.
[Client]
# Password = your_password
Port = 3305 #3306
Socket =/tmp/MySQL. Sock
Default-character-set = utf8
[Mysqld]
Port = 3305 #3306
Socket =/tmp/MySQL. Sock
Skip-locking
Key_buffer = 256 m
Max_allowed_packet = 1 m
Table_cache = 256
Sort_buffer_size = 1 m
Read_buffer_size = 1 m
Read_rnd_buffer_size = 4 m
Myisam_sort_buffer_size = 64 m
Thread_cache_size = 8
Query_cache_size = 16 m
Default-character-set = utf8
View the database show variables like '% char %'; view the character set
+ -------------------------- + ------------------------------------------------------------ +
| 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-5.1.34-linux-i686-glibc23/share/charsets/|
+ -------------------------- + ------------------------------------------------------------ +
If not, set character_set_client = UTF-8;
To change the character set.
Now, restart MySQL.
Then PHP is garbled. It is best to encode the PHP file as utf8.
This is the case. If the code is garbled, check whether your browser code is utf8. Let's go here. Although it cannot solve all the garbled issues, but it should be able to solve part of the problem, hoping to be useful to you.