Sometimes, in half of cases - Drupal very not clearly works with mysql
http://drupal.org/node/39518

I in confusion
On other server (php5+mysql5+apache2+freebsd) where all is for the present normal - through phpmyadmin Russian letters through phpMyAdmin too are visible so
функции / процессы

It has occured after small updating php+apache+mysql thus phpMyadmin as before and now normally writes and reads the base and old Drupal tables, and Drupal began to write and read mysql through any code conversion.

Probably it is bug Drupal

Comments

kiev1.org’s picture

Interesting problem. It is connected with a case when the mysqld: utf8 and the encoding mysqlclient is not defined.
In a file database.mysql.inc has added in the end of function db_connect here such code
mysql_query (" SET NAMES utf8 ");

and all has earned!

Probably to solve it it is more correct?

rkerr’s picture

There are a few places where the character sets could to wrong..
Check that your my.cnf has

[server]
default-character-set=utf8
character-set-server=utf8

[client]
default-character-set=utf8

and that the character set of your database is utf8,
also that the character set of your tables is utf8.

The thing is, PHP has its own idea of what character set to use as default for MySQL connections... as far as I know, it doesn't check the [client] section of the my.cnf file. So...

To ensure that PHP is really using utf8 for your connection to the database, you should use:

mysql_query("SET NAMES utf8;");
mysql_query("SET CHARACTER SET utf8;");

I have one site where I've patched database.mysql.inc to always execute those 2 queries in the db_connect function because I know my tables are in utf8. This problem may be better solved long-term by having something defined, maybe in settings.php that would be used as the character set for the site.

kiev1.org’s picture

Thanks! Editing my.cnf (mysql5) work on FreeBSD only, and on Gentoo for some reason helps only mysql_query (" SET NAMES utf8 ");. In any case it is the most reliable recompile mysql with utf8 by default

Wesley Tanaka’s picture

see also the patch at: http://drupal.org/node/40515

greggles’s picture

Component: base system » mysql database
Status: Active » Closed (duplicate)

As wtanaka points out, this seems like a duplicate of http://drupal.org/node/40515