是否有我可以运行的 SQL
或 PHP
脚本来更改数据库中所有表和字段中的默认排序规则?
Is there a SQL
or PHP
script that I can run that will change the default collation in all tables and fields in a database?
我可以自己写一个,但我认为这应该在这样的网站上很容易获得.如果我能在有人发布之前自己想出一个,我会自己发布.
I can write one myself, but I think that this should be something that readily available at a site like this. If I can come up with one myself before somebody posts one, I will post it myself.
小心!如果您确实将 utf 存储为另一种编码,那么您的手上可能会一团糟.先备份.然后尝试一些标准方法:
Be careful! If you actually have utf stored as another encoding, you could have a real mess on your hands. Back up first. Then try some of the standard methods:
例如http://www.cesspit.net/drupal/node/898http://www.hackszine.com/blog/archive/2007/05/mysql_database_migration_latin.html
我不得不将所有文本字段转换为二进制,然后再转换回 varchar/text.这救了我的屁股.
I've had to resort to converting all text fields to binary, then back to varchar/text. This has saved my ass.
我的数据是UTF8,存储为latin1.我做了什么:
I had data is UTF8, stored as latin1. What I did:
删除索引.将字段转换为二进制.转换为utf8-general ci
Drop indexes. Convert fields to binary. Convert to utf8-general ci
如果你在 LAMP 上,不要忘记在与数据库交互之前添加 set NAMES 命令,并确保你设置了字符编码头.
If your on LAMP, don’t forget to add set NAMES command before interacting with the db, and make sure you set character encoding headers.
这篇关于在MYSQL中将所有表和字段更改为utf-8-bin排序规则的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!