phpmyadmin display utf8
By ET
Took me a whole afternoon to figure it out.
MySQL used non-utf-8 encoding, so when I use phpmyadmin to interpret it, the returned result is messed up.
mysql> show variables like ‘character_set%’;
+————————–+——————————–+
| Variable_name | Value |
+————————–+——————————–+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | \mysql\share\charsets\ |
+————————–+——————————–+
8 rows in set (0.00 sec)
mysql> show variables like ‘collation%’;
+———————-+——————-+
| Variable_name | Value |
+———————-+——————-+
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_general_ci |
| collation_server | latin1_general_ci |
+———————-+——————-+
3 rows in set (0.00 sec)
I wrote a program to query the DB and used the following code to check if the characters are indeed utf-8:
use strict;
use Encode;
my $iftest=1;
my $ifpause=1;
use DBI;
my $conn = DBI->connect ("DBI:mysql:ki","","") or die("Cannot connect: $DBI::errstr");
$conn->{RaiseError} = 0;
my $sql;
my $query;
my $row;
my $id=1;
$sql=qq(select * from categorylinks );
$query = $conn->prepare($sql);
$query->execute or print("n[Select ID]Error executing SQL statement! $DBI::errstrn”);
while ($row = $query->fetchrow_arrayref){ my $line=@$row[1];
$line=decode(”utf8″,$line);
$line=encode(”gbk”,$line);
print “$linen”;
} $conn->disconnect;
exit;
Turned out that the output are correct.
By phpmyadmin still outputs messy code for Chinese, so I modified the following file
/phpMyAdmin/libraries/select_lang.lib.php
Under “// MySQL charsets ma”
Changed from
‘utf-8′ => ‘utf8′,
To
‘utf-8′ => ‘latin1′,
Voila, it worked

May 8th, 2008 at 5:29 pm
It has to do with the internal storage of the characters. I guess this works as a quick fix, it does not mean the database is configured properly.
May 8th, 2008 at 9:52 am
wow it work! Thanks a lot.
——————————————–
but I am confused.
‘utf-8′ => ‘utf8′, It’s correct,but messed up the display result.
‘utf-8′ => ‘latin1′ It’s is uncorrect,but fixed the problem.
WHAT THE HELL WAS THAT
May 7th, 2008 at 6:33 pm
Many thanks, this solved my problem!
May 5th, 2008 at 5:37 am
Thank you. It works for lithuanian language too.
December 25th, 2007 at 1:05 am
if the purpose is just for phpmyadmin to display chinese utf8 chars correctly, you can set charset to utf8 either at db, table, or column level, such as
create table foo (name varchar(255) set charset utf-8); OR
create table foo (name varchar(255)) set charset utf-8
I have tried it. phpmyadmin does display the chinese characters correctly.
I have a different problem — those utf8 chars don’t show up correctly in php applications.
November 29th, 2007 at 8:03 am
Thanks, this was a solution for my problem too!
May 3rd, 2007 at 2:47 pm
Cool.
May 1st, 2007 at 11:18 pm
This worked for me. Great find, thanks.