开发者

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

开发者 https://www.devze.com 2023-03-18 17:19 出处:网络
Because mysql default settings are not quite Unicode friendly it can happen quite often to endup with a database with broken charset.

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

精彩评论

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

关注公众号