站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
建站程序
开发
服务器
办公软件
开发教程
服务器教程
软件使用教程
运营教程
热门电子书
WordPress教程
宝塔面板教程
CSS教程
Shopify教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Converting Database Character Sets
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
高级
特殊字符
帮助
标题
2级
3级
4级
5级
格式
插入
拉丁字母
扩展拉丁字母
国际音标
符号
希腊字母
希腊字母扩展
西里尔字母
阿拉伯字母
扩展阿拉伯字母
希伯来字母
孟加拉语字符集
泰米尔数字和符号
泰卢固语字符集
僧伽罗语字符集
梵文字符集
古吉拉特语字符集
泰语字符集
老挝语
高棉语字母
加拿大原住民音节文字
卢恩
Á
á
À
à
Â
â
Ä
ä
Ã
ã
Ǎ
ǎ
Ā
ā
Ă
ă
Ą
ą
Å
å
Ć
ć
Ĉ
ĉ
Ç
ç
Č
č
Ċ
ċ
Đ
đ
Ď
ď
É
é
È
è
Ê
ê
Ë
ë
Ě
ě
Ē
ē
Ĕ
ĕ
Ė
ė
Ę
ę
Ĝ
ĝ
Ģ
ģ
Ğ
ğ
Ġ
ġ
Ĥ
ĥ
Ħ
ħ
Í
í
Ì
ì
Î
î
Ï
ï
Ĩ
ĩ
Ǐ
ǐ
Ī
ī
Ĭ
ĭ
İ
ı
Į
į
Ĵ
ĵ
Ķ
ķ
Ĺ
ĺ
Ļ
ļ
Ľ
ľ
Ł
ł
Ń
ń
Ñ
ñ
Ņ
ņ
Ň
ň
Ó
ó
Ò
ò
Ô
ô
Ö
ö
Õ
õ
Ǒ
ǒ
Ō
ō
Ŏ
ŏ
Ǫ
ǫ
Ő
ő
Ŕ
ŕ
Ŗ
ŗ
Ř
ř
Ś
ś
Ŝ
ŝ
Ş
ş
Š
š
Ș
ș
Ț
ț
Ť
ť
Ú
ú
Ù
ù
Û
û
Ü
ü
Ũ
ũ
Ů
ů
Ǔ
ǔ
Ū
ū
ǖ
ǘ
ǚ
ǜ
Ŭ
ŭ
Ų
ų
Ű
ű
Ŵ
ŵ
Ý
ý
Ŷ
ŷ
Ÿ
ÿ
Ȳ
ȳ
Ź
ź
Ž
ž
Ż
ż
Æ
æ
Ǣ
ǣ
Ø
ø
Œ
œ
ß
Ð
ð
Þ
þ
Ə
ə
格式
链接
标题
列表
文件
参考
讨论
说明
输入内容
输出结果
斜体
''斜体文字''
斜体文字
粗体
'''粗体文字'''
粗体文字
粗斜体
'''''粗斜体文字'''''
粗斜体文字
==转变你的数据库== Before beginning any conversion, please backup your database. [[WordPress:Backing Up Your Database]] has easy-to-follow instructions. 在开始任何操作之前,请备份你的数据库。[[WordPress:Backing Up Your Database|备份你的数据库]]有简单容易掌握的说明。 For discussion purposes, it is assumed you have a database in the '''latin1''' character set that needs converting to a '''utf8''' character set. 为了便于讨论,加入你在'''latin1'''字符集中有个数据库,这个数据库需要转变到'''utf8'''字符集。 ===The Problem=== ===问题=== To convert character sets requires using the the MySQL ALTER TABLE command. When converting the character sets, all TEXT (and similar) fields are converted to UTF-8, but that conversion will BREAK existing TEXT because the conversion expects the data to be in latin1, but WordPress may have stored unicode characters in a latin1 database, and as a result, data could end up as garbage after a conversion! 要转变字符集,需要使用MySQL ALTER TABLE command。转变字符集的时候,所有的文本(和相似的)栏,都转变为UTF-8,但是转变会会破坏当前的文本,因为转变期望数据是在latin1,但是WordPress可能将统一的字符储存在latin1数据库,因此,转变后,数据可能变成没用的乱码。 ===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: 例子步骤: # Place notice that blog is out of service # Backup database # ALTER TABLE wp_users MODIFY display_name BLOB; # ...ALTER TABLE commands for all other tables/columns... # ALTER DATABASE wordpress charset=utf8; # ALTER TABLE wp_users charset=utf8; # ...ALTER TABLE command for all other tables... # ALTER TABLE wp_users MODIFY display_name TEXT CHARACTER SET utf8; # ...ALTER TABLE for all other tables/columns... # Add DB_CHARSET and DB_COLLATE definitions to [[WordPress:Editing_wp-config.php|wp-config.php]] # Place blog back on-line # 张贴通知,博客不能够正常运行 # 备份数据库 # 更改表格 wp_users 更改 display_name 博客; # ...为所有其它的表格/栏更改表格命令行... # 更改数据库 wordpress charset=utf8; # 更改表格 wp_users charset=utf8; # ...ALTER TABLE command for all other tables... # 更改表格 wp_users MODIFY display_name 文本字符集 utf8; # ...为所有其它的表格/栏更改表格... # 向 [[WordPress:Editing_wp-config.php|wp-config.php]]添加DB_CHARSET 和DB_COLLATE定义 # 使博客重新上线,运行 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 * CHAR -> BINARY * VARCHAR -> VARBINARY * TINYTEXT -> TINYBLOB * TEXT -> BLOB * MEDIUMTEXT -> MEDIUMBLOB * LONGTEXT -> LONGBLOB This information was originally posted by member g30rg3x in [http://wordpress.org/support/topic/117955 Forum Thread 117955]. ENUM and SET have more specific conversion rules: 这个信息,最初是由g30rg3x成员在[http://wordpress.org/support/topic/117955 论坛主题 117955]上发表的。 Set the character set to binary, or to UTF8 if you are sure that no ENUM or SET field has special characters that might get garbled during conversion. 如果你确定没有ENUM 或者 SET field中不能转变的字符,请将字符集设置为二进制的,或者设置为UTF8 The SQL for this is: SQL是: * ALTER TABLE wp_links CHANGE link_visible link_visible ENUM('Y','N') CHARACTER SET utf8; *更改表格wp_links CHANGE link_visible link_visible ENUM('Y','N') CHARACTER SET utf8; The field name does need to be repeated, as well as the ENUM specification. 不需要重复栏的名称和ENUM规定。 When specifying BINARY and VARBINARY, the field length also needs to be specified, and needs to be the same value as the original CHAR and VARCHAR field length. In other words, VARCHAR(200) becomes VARBINARY(200). 规定二进制和VARBINARY的时候,也要规定栏的长度,而且需要与原始的CHAR和VARCHAR栏的长度相同。换句话说,VARCHAR(200) 变成了 VARBINARY(200)。 So, in Steps 3 and 4 change CHAR, VARCHAR, TEXT, ENUM, and SET fields to their binary counterparts (BLOB, VARBINARY, etc), in Step 5 switch the database to utf8, in Steps 6 and 7 switch all the tables to utf8, and finally, in Steps 8 and 9 return the binary fields back to the respective CHAR, VARCHAR, TEXT, ENUM, and SET data types with the utf8 character set. 因此,在第三步和第四步,更改CHAR, VARCHAR, TEXT, ENUM,并且将栏设置为相应的二进制(BLOB, VARBINARY, 等等),在第五步中,将数据库转变为utf8,在第六步和第七步中,将所有的表格转变为utf8,最后,在第八步和第九步中,将二进制栏重新返回为各自的CHAR, VARCHAR, TEXT, ENUM,并且使用utf8字符集设置数据类型。 The key to the conversion is that a field with a binary data type, unlike CHAR, VARCHAR, TEXT, ENUM, and SET fields, will not be converted to garbage when the database and tables are switched to utf8. 转换的关键在于,带有二进制数据类型的栏,不像CHAR, VARCHAR, TEXT, ENUM和SET栏,当数据库和表格转变为utf8,这种栏,不会变为乱码。 ====Conversion Scripts and Plugins==== ====转变脚本和插件==== In the WordPress Forums, Member andersapt, in [http://wordpress.org/support/topic/117955 Forum Thread 117955] submitted a conversion script, [http://kunde.apt.no/aso/wordpress/convert_to_utf8_sql_generator.txt Convert UTF8 SQL Generator], to automatically convert a WordPress database. (This link is currently dead.) 在WordPress论坛中,成员andersapt在[http://wordpress.org/support/topic/117955 论坛主题 117955]中递交了一个转变脚本,[http://kunde.apt.no/aso/wordpress/convert_to_utf8_sql_generator.txt Convert UTF8 SQL Generator],自动转变WordPress数据库。(这个链接当前不能够运行。) A plugin, [http://g30rg3x.com/utf8-database-converter/ UTF-8 Database Converter], is available from g30rg3_x. Carefully review the readme file included with the plugin. This plugin corrupts data in modern versions of Wordpress. 插件[http://g30rg3x.com/utf8-database-converter/ UTF-8 数据库转换器],可以在g30rg3_x得到。仔细阅读插件中的readme文件,这个插件破坏了新版本中的WordPress的数据。
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)