开发者

Inconsistent MySQL COLLATE errors across databases

开发者 https://www.devze.com 2022-12-23 05:55 出处:网络
I have two physically-separate MySQL databases on which I have to run a single query. The query has a section of SQL that looks like this:

I have two physically-separate MySQL databases on which I have to run a single query.

The query has a section of SQL that looks like this:

and foo_table.bar_column like concat('%', rules.pattern, '%') COLLATE utf8_general_ci

It runs fine on database A but on database B I get this error:

ERROR 1253 (42000): COLLATION '开发者_开发技巧utf8_general_ci' is not valid for CHARACTER SET 'latin1'

If I remove the collation it runs fine on database B but on database A I get this error:

ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation 'like'

Is there a version of the query that will run on both databases?

Or, is there a configuration I can change on either database to make the query happy in both places?

Update:

Database A is version 5.1.38, Database B is version 5.1.34


Some promising information here.

UPDATE: the suggestions in that link solved my problem, although the syntax is a little out of date and you don't have to convert each column anymore, just the table.

ALTER TABLE the_latin_one CONVERT TO CHARACTER SET utf8;
0

精彩评论

暂无评论...
验证码 换一张
取 消