0

I want to create DB with utf8_general_ci collation. I've defined the MySQL connection collation as utf8_general_ci (in phpmyadmin), and I've defined charset: UTF8 in config.yml but when I use php app/console doctrine:schema:update --force it create a table with latin1_swedish_ci collation. Is there a way to fix it?

Shimon S
  • 4,048
  • 2
  • 29
  • 34

1 Answers1

0

I think the best thing is to change MySQL setting directly. Add this to your my.ini file (MYSQL configuration file):

[mysqld]
character-set-server=utf8
default-collation=utf8_general_ci

I saw once a trick to do it directly from Symfony but it was requiring to change some internal code of Doctrine and it wasn't even working in my case.

I end up adding those settings to my.ini file.

Edit: Some links on how to change charset and collation on MySQL

  1. change mysql default character set to UTF8 in my.cnf?
  2. MySQL 5.0 Reference guide

Regards, Matt

Community
  • 1
  • 1
Matt
  • 10,633
  • 3
  • 46
  • 49
  • I did as you suggested, I stopped mysql service and now I can not run it back. Only when I delete these two lines I added in my.ini just so I can start the Mysql back. – Shimon S Apr 23 '12 at 21:04
  • Well. I did this: ALTER TABLE mytable CONVERT TO CHARACTER SET utf8 – Shimon S Apr 23 '12 at 21:41
  • Did you add the three lines, `[mysqld]` is important. The alter should not have caused any problem. – Matt Apr 24 '12 at 03:30
  • This is odd, reading the reference guide says to do exactly this. Dunno what could go wrong. Sorry it don't work as expected ... – Matt Apr 24 '12 at 18:30