如何在phpMyAdmin中显示UTF-8字符? [英] How to display UTF-8 characters in phpMyAdmin?

查看:162
本文介绍了如何在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).

已为数据库和所有表正确设置了字符集(在文件的任何位置均未找到拉丁")

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:

在函数PMA_DBI_connect()末尾的文件/usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php中,在我添加的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中看到日语字符. WTF?为什么这样做有效?

And it works! I now see Japanese characters in phpMyAdmin. WTF? Why does this work?

这篇关于如何在phpMyAdmin中显示UTF-8字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆