MySQL非法混合排序规则

时间:2012-09-03 11:40:01

标签: mysql symfony collation symfony-2.1 fosuserbundle

查看我的prod日志后,我提到了一些错误:

[2012-08-31 15:56:43] request.CRITICAL: Doctrine\DBAL\DBALException: 
An exception occurred while executing 'SELECT t0.username ....... FROM fos_user t0 WHERE t0.username = ?'
with params {"1":"Nrv\u29e7Kasi"}:

SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
and (utf8_general_ci,COERCIBLE) for operation '=' 

Alghout我在学说cfg:

下有UTF-8默认值
doctrine:
    dbal:
        charset:  UTF8

似乎我的所有MySQL表都在latin1_swedish_ci中,所以我的问题是:

我是否可以手动将排序规则更改为utf8_general_ci,无需任何复杂/预防措施?

2 个答案:

答案 0 :(得分:8)

多数民众赞成。我遇到了这个问题,最好的快速和快速的解决方案是

         CONVERT(fos_user.username USING utf8)

答案 1 :(得分:3)

只需按命令转换表的字符集,如下所示,

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8;