Skip to content


我的Wordpress又升级了

感觉升级的次数比写blog的次数还要多,不过这一次我要好好写写升级的过程,也算给和我同样遭遇的wordpress用户一个提示。

因为从2.0就开始使用wordpress了,那时使用的数据库编码经常不是utf8的,所以创建表的语句就象这样:

CREATE TABLE `rs_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` int(11) NOT NULL default '0',
`comment_author` tinytext collate latin1_general_ci NOT NULL,
`comment_author_email` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_author_url` varchar(200) collate latin1_general_ci NOT NULL default '',
`comment_author_IP` varchar(100) collate latin1_general_ci NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text collate latin1_general_ci NOT NULL,
`comment_karma` int(11) NOT NULL default '0',
`comment_approved` enum('0','1','spam') collate latin1_general_ci NOT NULL default '1',
`comment_agent` varchar(255) collate latin1_general_ci NOT NULL default '',
`comment_type` varchar(20) collate latin1_general_ci NOT NULL default '',
`comment_parent` bigint(20) NOT NULL default '0',
`user_id` bigint(20) NOT NULL default '0',
PRIMARY KEY  (`comment_ID`),
KEY `comment_approved` (`comment_approved`),
KEY `comment_post_ID` (`comment_post_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=40397 ;

而最新的wordpress,导出来的表对应的都是utf8编码的,所以应该把上述语句替换为:

CREATE TABLE `rs_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` int(11) NOT NULL default '0',
`comment_author` tinytext  NOT NULL,
`comment_author_email` varchar(100)  NOT NULL default '',
`comment_author_url` varchar(200)  NOT NULL default '',
`comment_author_IP` varchar(100)  NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text  NOT NULL,
`comment_karma` int(11) NOT NULL default '0',
`comment_approved` enum('0','1','spam')  NOT NULL default '1',
`comment_agent` varchar(255)  NOT NULL default '',
`comment_type` varchar(20)  NOT NULL default '',
`comment_parent` bigint(20) NOT NULL default '0',
`user_id` bigint(20) NOT NULL default '0',
PRIMARY KEY  (`comment_ID`),
KEY `comment_approved` (`comment_approved`),
KEY `comment_post_ID` (`comment_post_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=40397 ;

注意我的单个字段也有编码设置,应该都清除掉。然后我们就把这些数据用phpmyadmin导入到数据库里,如果顺利地话通过phpmyadmin 看到的都是正常的汉字。然后升级文件,网上提到要修改wp-config的设置,我觉得那都不是长远之计,最好不修改。把最新版本的wp-config- sample.php,改名为wp-config.php,然后修改其中的数据库连接信息,上传到服务器上就好了。跑到wp-admin下就会自动提示需要升级结构,点确定就可以了,然后我们就有了完全utf8环境的wordpress了。

Related posts:

  1. My first wordpress plugin
  2. Flash Zoom
  3. Watermark: With GIMP Script
  4. Wordpress升级
  5. Django 1.0之后的文件上传

Posted in blog, program, recommend. Tagged with , , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.