Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the character set mismatch problem of mysql query

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to solve the mysql query character set mismatch problem, the article is very detailed, has a certain reference value, interested friends must read it!

Sometimes the MySQL database uses the latin character set when building the table, while the query in the web page is utf-8. When the input page is typed in Chinese, and then queried in the database, it will report the error of ER_CANT_AGGREGATE_2COLLATIONS: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation'=', so the database is found in stackover flow. And the method of changing the character set in the data table.

SET collation_connection = 'utf8_general_ci'

Note: to replace the following two sentences with your database name and your 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, so that there will be no errors in querying the contents of the database when typing in Chinese.

Reference:Illegal mix of collations MySQL Error

Set the character set of the database to utf-8 in PHP

Mysqli_set_charset ($dbc,'utf8')

Just add a meta that displays utf-8 to html.

The above is how to solve the mysql query character set mismatch all the content, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report