How to display UTF-8 characters in phpMyAdmin?(如何在 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?
这篇关于如何在 phpMyAdmin 中显示 UTF-8 字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 phpMyAdmin 中显示 UTF-8 字符?
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01