Solution to the Problem of Character Set mismatch in mysql query, mysql Character Set

Source: Internet
Author: User

Solution to the Problem of Character Set mismatch in mysql query, mysql Character Set

Problems Found

Recently, I encountered a problem in my work. When creating a table in MySQL database, I used the latin character set while the query on the webpage was UTF-8. When I enter Chinese characters on the input page, then, when querying in the database, it will reportER_CANT_AGGREGATE_2COLLATIONS: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='This error occurs, so we found the method for changing the character set in the database and data table in stackover flow.

SET collation_connection = 'utf8_general_ci' 

Note:Replace the following two statements with your database name and data table name.

ALTER DATABASE your_database_name CHARACTER SET utf8 COLLATE utf8_general_ci  ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci 

This ensures that the database is also a UTF-8 character set and will not generate an error when querying the database content during Chinese input.

Reference: Illegal mix of collations MySQL Error

Set the database character set to UTF-8 in PHP

mysqli_set_charset($dbc,'utf8'); 

Add the meta that displays UTF-8 in html.

<meta charset="utf-8"> 

Summary

Well, the above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, you can leave a message, thank you for your support.

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.