[thelist] utf8 characters displaying as question marks with imported database

Dave M G martin at autotelic.com
Thu Apr 27 03:41:23 CDT 2006

The List,

I've cross-posted this to the MySQL mailing list, but it has not 
received any response there. I'm hoping perhaps someone here might have 
experience with encoding issues.

I have a database on a server that contains English and Japanese text. I 
have tried to ensure at every turn that all text encoding is in utf8.

On the web hosting server where the live site resides, everything is 
working fine.

But on my testing environment at home, the Japanese text displays as 
question marks.

Japanese text that is written directly into the PHP/HTML displays 
correctly. Only Japanese text retrieved from the database displays 

All the Japanese text was initially entered on the hosting server. To 
get the database duplicated onto my testing environment, I exported the 
database, and then imported it again. I also checked the .sql file that 
was generated to ensure that the utf8 encoded Japanese was still 
readable as Japanese before importing it.

Further, when I look at the database in phpMyAdmin, it displays the 
Japanese correctly.

I had a similar problem a few months back, and at the time, it was 
advised that I add the following lines to /etc/mysql/my.cnf:
init-connect='SET NAMES utf8'

I've done this, and so these are my collation variables:

Variable   Session value   Global value
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     /usr/share/mysql/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

This solved the problem last time.

But this time the same solution does not seem to be working.

I hope I have described the problem in enough detail. If not, please let 
me know.

Is there any other character set related setting that I may need to do 
on my local MySQL server to correctly display Japanese?

My home set up:
Ubuntu Dapper Drake 6.06
MySQL MySQL 4.1.15
phpMyAdmin 2.7
PHP 4.4.2

Any help would be much appreciated.

Thank you.

Dave M G

More information about the thelist mailing list