Skip to content

Commit e9e4324

Browse files
committed
Merge pull request #1563 from Inori/database-note
added a note about database default charsets/collations
2 parents d9d25fe + 9f10837 commit e9e4324

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

book/doctrine.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ information. By convention, this information is usually configured in an
7979
of your project, like inside your Apache configuration, for example. For
8080
more information, see :doc:`/cookbook/configuration/external_parameters`.
8181

82+
.. sidebar:: Setting Up The Database
83+
84+
One mistake even seasoned developers make when starting a Symfony2 project
85+
is forgetting to setup default charset and collation on their database,
86+
ending up with latin type collations, which are default for most databases.
87+
They might even remember to do it the very first time, but forget that
88+
it's all gone after running a relatively common command during development:
89+
90+
.. code-block:: bash
91+
92+
$ app/console doctrine:database:drop --force
93+
$ app/console doctrine:database:create
94+
95+
There's no way to configure these defaults inside doctrine, as it tries to be
96+
as agnostic as possible in terms of enviroment configuration. One way to solve
97+
this problem is to configure server level defaults.
98+
99+
Setting UTF8 defaults for MySQL is as simple as adding a few lines to configuration file
100+
(typically ``my.cnf``):
101+
102+
.. code-block:: ini
103+
104+
[mysqld]
105+
collation-server = utf8_general_ci
106+
character-set-server = utf8
107+
82108
Now that Doctrine knows about your database, you can have it create the database
83109
for you:
84110

0 commit comments

Comments
 (0)