Bug #4002 can't set charset for clients
Submitted: 4 Jun 2004 13:00 Modified: 18 Jun 2004 12:32
Reporter: Konstantin Samorodov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.2 OS:FreeBSD (FreeBSD 5.2)
Assigned to: CPU Architecture:Any

[4 Jun 2004 13:00] Konstantin Samorodov
Description:
I have compiled mysql-server 4.1.2 with option WITH_CHARSET=koi8r (as usualy) from ports FreeBSD but when I get status information from the server I see:
Client characterset:    koi8r_general_ci
Server characterset:    latin1_swedish_ci

All my tables are in koi8r. So, instead of right information I see something like that "???????"
Then I've tried to add in /etc/my.cnf follows:
[mysqld]
default-character-set=koi8r
[mysql]
default-character-set=koi8r
[client]
default-character-set=koi8r

After that I got status information:
Client characterset:    koi8r_general_ci
Server characterset:    koi8r_general_ci

So, in mysql console all is ok but problem is still staying for other mysql clients (PHP for example)
What is more, when I tried follows:
mysqladmin -uroot -p variables
I got
mysqladmin: ERROR: unknown variable 'default-character-set=koi8r'

I tried also to add that in my.cnf:
set-variable = character_set_client=koi8r

But for client it doesn't work and mysqladmin says:
mysqladmin: ERROR: unknown variable 'character_set_client=koi8r'

Here is a part of "show variables" for PHP client (script):
character_set_client latin1
character_set_connection latin1
character_set_database koi8r
character_set_results latin1
character_set_server koi8r
character_set_system utf8
character_sets_dir /usr/local/share/mysql/charsets/
collation_connection latin1_swedish_ci
collation_database koi8r_general_ci
collation_server koi8r_general_ci

Here is a part of "show variables" for mysql console:
| character_set_client            | koi8r                                                  |
| character_set_connection        | koi8r                                                  |
| character_set_database          | koi8r                                                  |
| character_set_results           | koi8r                                                  |
| character_set_server            | koi8r                                                  |
| character_set_system            | utf8                                                   |
| character_sets_dir              | /usr/local/share/mysql/charsets/                       |
| collation_connection            | koi8r_general_ci                                       |
| collation_database              | koi8r_general_ci                                       |
| collation_server                | koi8r_general_ci                                       |

Maybe I missed something in configuration? Can I ask the advice if it is not a bug?
Thank you

How to repeat:
Just repeat the sequence of my steps
[6 Jun 2004 2:26] MySQL Verification Team
Verified on Suse 9.0.
[7 Jun 2004 19:17] Hartmut Holzgraefe
regarding the error message you get with mysqladmin:

mysqladmin does not know the --default-character-set
so it does report an error when it finds it in the
[client] section of my.cnf

you can work around this by using 
'loose-default-character-set=...' instead.
[7 Jun 2004 21:16] Hartmut Holzgraefe
regarding PHP:

the PHP client library does not read the my.cnf 
option file so that any [client] settings won't 
affect it

to change character settings from within PHP
you have to issue "SET ..." queries to set
the character set and collation
[15 Jun 2004 16:45] Hartmut Holzgraefe
Should be fixed in 4.1.3, i can't compile our internal source 
right now to verify this but will as soon as possible ...
[18 Jun 2004 12:32] Hartmut Holzgraefe
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

will be working as you expected in 4.1.3 (even with PHP if you link it against the 4.1.3 client lib)
[22 Jun 2004 13:01] Sergey Kostyliov
I believe that this bug is a duplicate for #3990: 
http://bugs.mysql.com/bug.php?id=3990, and I can confirm that it is fixed in 
current 4.1-bk :).