修复 mysql 数据库上的字符集和排序规则的最简单方法?
因为 mysql 默认设置对 Unicode 不太友好,所以经常会出现数据库字符集损坏的情况。
通常您只想将其重新配置为使用 utf8
字符集和 utf8_unicode_ci
排序规则。
对于给定的数据库执行此操作最简单的命令是哪一个?
警告:不要发布未经测试的脚本的链接,我测试了至少 5 个脚本(用 bash/perl/php/python 编写),它们都无法修复数据库,其中排序规则在数据库和表级别设置正确,但在列级别。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法自己编写了一个解决方案并发布到:
https://gist.github.com/1068021
:
免费发布错误或补丁,我会尽力快速解决它们。
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.Feed free to post bugs or patches, I will try to solve them fast.