如何在 phpMyAdmin 中显示 UTF-8 字符?
我的数据库已正确设置为 UTF-8,并且正在处理包含日语字符的数据库.如果我从 mysql 命令行执行 SELECT *... ,我会正确地看到日语字符.从数据库中提取数据并在网页上显示时,我正确地看到了.
I have my database properly set to UTF-8 and am dealing with a database containing Japanese characters. If I do SELECT *... from the mysql command line, I properly see the Japanese characters. When pulling data out of the database and displaying it on a webpage, I see it properly.
然而,在phpMyAdmin中查看表格数据时,我只看到垃圾文本.即.
However, when viewing the table data in phpMyAdmin, I just see garbage text. ie.
ç§ã¯æ—¥æœ¬æ–™ç†ãŒå好ãã§ã™ã€‚日本料ç†ã‚...
ç§ã¯æ—¥æœ¬æ–™ç†ãŒå¥½ãã§ã™ã€‚日本料ç†ã‚...
如何让 phpMyAdmin 显示日文字符?
How can I get phpMyAdmin to display the characters in Japanese?
HTML 页面上的字符编码设置为 UTF-8.
The character encoding on the HTML page is set to UTF-8.
我尝试导出我的数据库并在 geany 中打开 .sql 文件.即使编码设置为 UTF-8,字符仍然是乱码.(但是做数据库的mysqldump也显示乱码)
I have tried an export of my database and opened up the .sql file in geany. The characters are still garbled even though the encoding is set to UTF-8. (However, doing a mysqldump of the database also shows garbled characters).
为数据库和所有表正确设置了字符集(在文件中的任何地方都找不到'latin')
The character set is set correctly for the database and all tables ('latin' is not found anywhere in the file)
CREATE DATABASE `japanese` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
我已将这些行添加到 my.cnf 并重新启动了 mysql,但没有任何变化.我正在使用 Zend Framework 向数据库中插入数据.
I have added the lines to my.cnf and restarted mysql but there is no change. I am using Zend Framework to insert data into the database.
我要为这个问题悬赏,因为我真的很想弄清楚这一点.
I am going to open a bounty for this question as I really want to figure this out.
推荐答案
我做了更多的谷歌搜索,发现了 这个页面
I did a little more googling and came across this page
该命令似乎没有意义,但我还是尝试了:
The command doesn't seem to make sense but I tried it anyway:
在文件/usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php 中 PMA_DBI_connect()
函数末尾的 return
我添加的声明:
In the file /usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php at the end of function PMA_DBI_connect()
just before the return
statement I added:
mysqli_query($link, "SET SESSION CHARACTER_SET_RESULTS =latin1;");
mysqli_query($link, "SET SESSION CHARACTER_SET_CLIENT =latin1;");
它有效!我现在在 phpMyAdmin 中看到了日语字符.跆拳道?为什么这样做?
And it works! I now see Japanese characters in phpMyAdmin. WTF? Why does this work?
相关文章