Thứ Sáu, 30 tháng 7, 2010

Converting Database Character Sets

The Solution

The solution is to ALTER all TEXT and related fields to their binary counterparts, then alter the character set and finally change the binary data type fields back to TEXT.

Example steps:

1. Place notice that blog is out of service
2. Backup database
3. ALTER TABLE wp_users MODIFY display_name BLOB;
4. ...ALTER TABLE commands for all other tables/columns...
5. ALTER DATABASE wordpress charset=utf8;
6. ALTER TABLE wp_users charset=utf8;
7. ...ALTER TABLE command for all other tables...
8. ALTER TABLE wp_users MODIFY display_name TEXT CHARACTER SET utf8;
9. ...ALTER TABLE for all other tables/columns...
10. Add DB_CHARSET and DB_COLLATE definitions to wp-config.php
11. Place blog back on-line

The string field types need to be converted to their binary field types counterparts. The list is as follows:

* CHAR -> BINARY
* VARCHAR -> VARBINARY
* TINYTEXT -> TINYBLOB
* TEXT -> BLOB
* MEDIUMTEXT -> MEDIUMBLOB
* LONGTEXT -> LONGBLOB

Tham khảo ở ĐÂY

Không có nhận xét nào: