Coding problem of MySQL storage garbled

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.