环境:Apache+php+mysql在windows Bugfree1.0
Mysql已经设置为缺省为utf8,我安装完成后,在PhpMyAdmin看BugModule等表内的数据可以正常显示中文,但是用Bugfree打开数据库时,显示中文全是问号,查了一下Bugfree的论坛,好像说是不支持mysql4.1,在网上搜索了一下,以下方法在我这里修改成功。
修改Bugfree/include/SetupBug.inc.php,在第60行增加一条设置字符集的语句:
$MyDB = &ADONewConnection("mysql");
$MyDB->Connect($BugConfig["BugDB"]["Host"],$BugConfig["BugDB"]["User"],$BugConfig["BugDB"]["Password"],$BugConfig["BugDB"]["Database"]);
$MyDB->Query("Set Names 'utf8'");//增加这一行,设定正确的字符集
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
我使用的版本说明:
- WinXp Sp2 中文版
- Apache HTTP Server 2.0.54:apache2.0.54.msi
-
PHP Version 5.0.5:php-5.0.5-Win32.zip
- phpMyAdmin 2.6.0-pl3
- MySQL 4.1.14-nt:mysql-4.1.14-win32.zip,安装时设置成UTF8
- BugFree 1.0:从phpmyadmin里面导入SQL来生成所有的表格和样例
从PhpMyAdmin里面可以查看MySql的字符集设置:
显示 MySQL 的系统变量 |
character set client | utf8 | utf8 |
character set connection | utf8 | utf8 |
character set database | utf8 | utf8 |
character set results | utf8 | utf8 |
character set server | utf8 | utf8 |
character set system | utf8 | utf8 |
character sets dir | E:/MySQL/share/charsets/ | E:/MySQL/share/charsets/ |
collation connection | utf8_general_ci | utf8_general_ci |
collation database | utf8_general_ci | utf8_general_ci |
collation server | utf8_general_ci | utf8_general_ci |
或直接从mysql命令行下查看:
mysql> Show variables like 'character_set_%';
+--------------------------+--------------------------+
| Variable_name | Value |
+--------------------------+--------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | E:/MySQL/share/charsets/ |
+--------------------------+--------------------------+
7 rows in set (0.00 sec)
mysql>
参考资料:
[推荐] [原创]完美解决XOOPS及WordPress在MySQL4.1之后版本中的乱码问题
by islq 2006-4-2