mysqlunicodeutf-8phpmyadmin

How to display UTF-8 characters in phpMyAdmin?


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.

However, when viewing the table data in phpMyAdmin, I just see garbage text. ie.

ç§ã¯æ—¥æœ¬æ–™ç†ãŒå¥½ãã§ã™ã€‚日本料ç†ã‚...

How can I get phpMyAdmin to display the characters in Japanese?

The character encoding on the HTML page is set to UTF-8.

Edit:

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;

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.


Solution

  • I did a little more googling and came across this page

    The command doesn't seem to make sense but I tried it anyway:

    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;");
    

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