問題描述
是否有我可以運行的 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模板網!