In the writing project, there are more garbled problems, the current note for the project is not garbled, in the storage of MySQL garbled.
1, through the following statement to see the database, the table client, server-side encoding is consistent, whether the Chinese can be stored.
Show variables like "%colla%", show variables like "%char%";
2, if the current encoding is consistent and supports the storage of Chinese, it is not a database encoding problem, otherwise it may be caused by inconsistent database encoding.
View the My.ini file in the path when the MySQL is installed view the Default-character-set settings, there are two clients one server at a time.
Change both places to UTF8 save after restarting MySQL service
3, through the following two sentences have been created before the database, the code of the table is fixed to the specified encoding, re-save the data from the project, then found that the database stored in Chinese is not garbled.
#SET character_set_client= ' UTF8 ';
#SET character_set_connection= ' UTF8 ';
#SET character_set_results= ' UTF8 ';
ALTER DATABASE ' test ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
ALTER TABLE ' test ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
Coding problem of MySQL storage garbled