19

查看我的产品日志后,我有一些错误提示:

[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为我的所有表格,而不会出现任何并发症/预防措施吗?

4

3 回答 3

61
于 2012-09-04T09:48:43.540 回答
9

Thats right. I ran into this problem and the best quick and fast solution is

         CONVERT(fos_user.username USING utf8)
于 2012-09-06T18:15:16.113 回答
4

Simply convert table's character set by command as follows,

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8;
于 2015-06-23T08:44:52.440 回答