Wordpress 升级至2.3.1,令人眩晕的编码问题
Blog沉寂了许久…不要说我懒–
其实我是很勤劳的!只是不体现在码字上罢了:P
看了看版本..2.0.X..是该升级一下wordpress了,跑去一看,人家都2.3.1了呢!
WordPress 2.3.1 is now available. 2.3.1 is a bug-fix and security release for the 2.3 series.
2.3.1 fixes over twenty bugs. Some of the notable fixes are:
Tagging support for Windows Live Writer
Fixes for a login bug that affected those with a Blog Address different than
their WordPress Address
Faster taxonomy database queries, especially tag intersection queries
Link importer fixes
Unfortunately, some security issues were found in 2.3. Janek Vind found an XSS problem that can be exploited if your php setup has register_globals enabled. For this reason, upgrading to 2.3.1 is advised.The full set of changes between 2.3 and 2.3.1 is available for viewing on trac.
Get 2.3.1 from the download page and enjoy.
曾经很期待的原生Tag,原来早就出来了。
看上去很诱人,动手~
禁用了所有插件,还原了默认主题以后覆盖。upgrade.php—数据库顺利升级!打开主页!
乱码..Orz
通常换主机才有的乱码情况,怎么会在升级的时候出现呢?Google之:
结果发现人家升级2.3.1都是出现源文件乱码,没人像我这样的- -
搜索以前版本的乱码情况,很多都是这样解决:
修改wp-includes/wp-db.php:
$this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
//加上下面这行
$this->query(”SET NAMES ‘utf8′”);
(via)
遂试验这种方法–乱码依旧。
琢磨应该是编码问题(废话..),打开phpMyAdmin发现数据库虽然连接校对是utf8_unicode_ci,但是表的编码为latin1_swedich_ci,数据库默认的编码也是latin1_swedich_ci…但是以前的wordpress一直写作编码是utf8。
按我的理解,也就是说,utf8被发送到数据库然后被当作latin1保存起来,然后读取的时候读出“在latin1看起来是乱码的DD”(所以phpmyadmin内查看表为乱码)给wordpress然后当作utf8显示出来(就不乱了Orz)。而这次新版的wordpress不知做了什么修改也开始按latin1显示文章(据我推测..因为乱码的形状一样…不要打我),所以产生了乱码。
既然原因已经找到(迷之音:你真的找到了吗?),那就把数据库转换成utf8吧!首先把数据库按照latin1编码dump出来(但是实际上是utf8):
mysqldump -u username -p databasename > database.sql --default-character-set=latin1
PS:这里我也试过按utf8来dump,但是dump出来是乱码,无论用什么编码都无法识别。
然后用一个支持多编码的编译器按照utf8打开(我使用emeditor)
搜索latin1全部替换为utf8(懒虫注意:这样就不用在phpmyadmin里一个一个的改啦!)
然后将文件另存为utf8编码
再把所有的表都drop掉,把新的sql文件按照utf8编码import回去:
mysql -u username -p databasename < database_utf8.sql --default-character-set=utf8
还在期待下一步吗?对不起,没有啦!欢迎使用5分钟去乱码(Orz)
为了进一步查明这个原因,google到了这篇文章MySQL中文乱码问题的解决
BTW,如果你看完了不头晕的话希望能给我讲解下…
PS:准备ssh的时候发现putty好像很久没有更新了..遂上网找新版,结果在这里发现了简体中文版(不是在简体系统上会乱码(Orz)的pietty喔),很好用。
类似的文章还有:
Comments
One Response to “Wordpress 升级至2.3.1,令人眩晕的编码问题”
Share your thoughts...
顶~~~~我叫IceYan,希望能交个朋友哈!^_^欢迎访问我的小站。IceYan的小站