When I was moving a database from old MySQL server (3.23.39) to a new one with updated MySQL I noticed
that character set can now be tuned for each database table separately.
Also older version of phpMyAdmin (2.3.0) which was installed on the obsolete server didn’t allow me
to see charsets but newer phpMyAdmin (2.6.4) does it well.
Setting default character set for a MySQL storage format can be done with the following query.
ALTER DATABASE `db_name` DEFAULT CHARACTER SET cp1251 COLLATE cp1251_bin
Everything appeared correctly in phpMyAdmin but in the browser I got texts in wrong encoding.
After some little digging I realized that MySQL 4.1 has some new features and now old
PHP scripts must be changed in order to show data in correct encoding.
This PHP code changes encoding for established PHP-MySQL session.
$query = "SET NAMES cp1251"; $result = MYSQL_QUERY($query); if (!$result) print "problem setting encoding...";
Thankfully database connection code was placed in separate .PHP file so it was easy to
fix encoding problem for the entire web site.
If this code will not help you this means that MySQL stores data in different charset.
Simply try to set same encoding type for PHP MySQL session and MySQL internal storage.
Later I found that this problem is actual for migration from 4.0 to 4.1 versions of MySQL.