开发者

Easiest way to repair charset and collation on a mysql database?

Because mysql default settings are not quite Unicode friendly it can happen quite often to endup with a database with broken charset.

Usually you just want to reconfigure it to use utf8 character set and utf8_unicode_ci collation.

Which is the easiest command to do this for a given database?

Warning: do not post links to untested scripts, I tested at least 5 of them (written in bash/perl/php/python) and they all failed to repair a database开发者_开发技巧 where the collation was set correctly at database and table level but not at column level.


I managed to write a solution myself and published to:

https://gist.github.com/1068021

Notes:

  • mysqldump is borken, even if tell it to not include CHARSET it will include them if it i set at column level.
  • this solution does not assume a default charset at mysql-server level so it set it at database level and resets it to defaults for table and column level.

Feed free to post bugs or patches, I will try to solve them fast.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜