I am using Doctrine with Symfony2. My config.yml file looks something like this:-
doctrine:
dbal:
driver: %data
The charset: UTF8
option is just useful to ask Doctrine to execute SET NAMES UTF-8
on each page. I don't have any specific configuration for Doctrine, and my tables are by default in utf8_general_ci
InnoDB.
Read this part of the documentation: https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/faq.html#how-do-i-set-the-charset-and-collation-for-mysql-tables, it answers your question:
You can’t set these values inside the annotations, yml or xml mapping files. To make a database work with the default charset and collation you should configure MySQL to use it as default charset, or create the database with charset and collation details. This way they get inherited to all newly created database tables and columns.