1

I set up a MySQL database, version 5.5.31. The default collation for the character set utf8mb4 is utf8mb4_general_ci (as shown by SHOW CHARACTER SET). I would like to change this to utf8mb4_unicode_ci.

Is there any way to change the default assignment from character sets to collations? Or is it hard-coded and compiled into the MySQL binary?

twonkeys
  • 552
  • 6
  • 11
  • http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf – Mad Dog Tannen Dec 03 '13 at 10:38
  • Sorry, but this does not answer my question. The referenced question shows how to set the default character set and encoding for the client-server connection. But it doesn't help if one creates a table specifying character set `utf8mb4` (without explicitly setting the collation) -- then the default collation `utf8mb4_general_ci` is used instead of the desired `utf8mb4_unicode_ci`. – twonkeys Dec 03 '13 at 11:16

1 Answers1

0
ALTER DATABASE db_name CHARACTER SET utf8mb4_unicode_ci;

See the reference here.

Mikhail Timofeev
  • 2,169
  • 15
  • 13
  • As this does change the CHAR SET for the database, it does not change it to be the standard CHAR SET when creating new SCHEMAS – Mad Dog Tannen Dec 03 '13 at 10:37
  • TS wants to change the char set of database, or have i missunderstood the question? – Mikhail Timofeev Dec 03 '13 at 10:41
  • When you `ALTER DATABASE db_name`, you change the setting of that database. But if you `CREATE DATABASE` it will still use the default settings of the server. Above code will not change that. – Mad Dog Tannen Dec 03 '13 at 10:49