Switch MySQL default charset to utf8mb4?

It is a fact that MySQL’s “unicode” charset/collation is incapable of storing all Unicode characters. Now this has been brought up as an issue in JIRA and I wonder how to “fix” this.

One option would be to point it out somewhere and mention the database:setcharset command, which can be used to fix this. But this solution has it’s drawbacks, especially during migrations (when new FK constraints need to be created.

So, another option would be to switch the default charset to utf8mb4 – again, if you count the introduction of charset/collation into our schema migrations. That would need at least MySQL 5.5 if I read their docs correctly.

I’d love to hear pros and cons from everyone!

I think I suggested that last year already when investigating some charset problems. I guess it would make sense, maybe some more research about needed MySQL versions and spread of those is needed. Also what about other DBs?

2 Likes

One con I just realized: we would (again) deviate from what doctrine:migrationgenerate produces out of the box, potentially leading to problems with mixed charsets.

Other databases handle this differently; PostgreSQL has a proper unicode charset support.