Hits: 433

装Wordpresss时中文显示“???”的问题小小困扰了俺一把,最后的解决方案是把wp-config.php的下面的utf8删除就一切搞定了。这个问题的原因是mqsql安装的时候,collation的默认是latin1_swedish_ci。对于中文博客,这个设置应该是utf8。网上找到以下的方法成功了,但是心病没去啊, mysql里的collation还是latin1_swedish_ci

 

改前:define(‘DB_COLLATE’, ‘utf8’);

改后:define(‘DB_COLLATE’, ”);

 

这不今天装limesurvey就又出问题了,找来找去,找不到类似上面WP的简单处理方式,最后终于在lime的手册里找到方法了, WP也可以用类似的方法处理。有两种情况

 

1.装好了Mysql, Limesurvey/wordpres还没装,  可以在phpMyAdmin这么来一下, 把<your_database_name>换成你的数据库名

ALTER DATABASE `<your_database_name>` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Replace <your_database_name> with the name of your database. You need to do this BEFORE installing LimeSurvey.

2. Mysql和Limesuurvey/Wordpress一起都装好了, 人家host的script也是好心么, 哥们妹们,你跟我一样得麻烦一些了

Go to phpMyAdmin and export your database file so that when you import it later, it overwrites every table that exists. To do that make sure "Add Drop Table" is checked and that "Add if NOT EXISTS" is unchecked. You can leave all other default settings in their current state.

进入phpMyAdmin导出数据库,记得将"Add Drop Table"勾上,"Add if NOT EXISTS"勾去

Make a copy of your exported file so that you have an original backup if anything goes wrong. Rename the duplicate file anything you like, e.g., rev_databasename.sql.

将导出的数据库备份

Open the duplicate text file in any word processing program such as MS Word or WordPad and conduct a find and replace on the words latin1 and utf8, respectively. That is, replace all instances of latin1 with utf8.

用word或wordpad之类编辑器将所有的latin1替换成utf8

Save and then close the file. Go back to phpMyAdmin and import the modified SQL database file. All preexisting latin1 collated tables should now be replaced with UTF8 collation. If you check the table structure in phpMyAdmin the new collation for each table will now read either "utf8_general_ci" or "utf8_unicode_ci" (depending on the table). This is precisely what you want.

改好的数据库存盘退出。回到phpmyadmin里导入改好的数据库。所有的collation现在应该都是utf8_general_ci了。 还行吧, 就1分钟的事。

You will need to reenter all your foreign language text and now it will display properly.

现在你的中文应该显示正常了

花絮: 受到鼓舞, 魔抓伸向了WP.意外的是数据库倒出来改好了, 却倒不回去。于是反复的改config.php,反复的把不同的书籍库备份倒来倒去,反复的ALTER DATABASE `<your_database_name>` DEFAULT 。。。最好还是一切回原样了事。

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

7 thoughts on “解决Limesurvey的中文乱码问题,跟WordPress有相似之处

  1. 这东西不灵,我安装了两天,没安装好,气得我,google一把,国内的,php的,找到enableq,试了试不错,可惜要钱。www.enableq.com.不过一个问卷的不要钱,刚看到,我够用了,哈哈哈

    1. 还好吧, 我装的很容易。呵呵,肯定是你的RP了。 简单的话找个web servcie,插一段代码就搞定。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.