Bug #25088 init-connect doesn't work properly
Submitted: 15 Dec 2006 9:00 Modified: 28 Dec 2006 7:49
Reporter: Yury Levin Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.0.30 OS:Linux (Debian Etch)
Assigned to: CPU Architecture:Any
Tags: character set, charset, init-connect

[15 Dec 2006 9:00] Yury Levin
Description:
I have an init-connect option in my.cnf:

init-connect="set names cp1251"

But it doesn't work. In any case, I've tried to see variables with mysql and mysqladmin tools and values of some were different.

How to repeat:
1) add init-connect="set names cp1251" to my.cnf
2) check it with following command:

   debian:/etc/mysql# mysqladmin variables | egrep "connection|collation"
| character_set_connection        | cp1251                      |
| collation_connection            | cp1251_general_ci           |
| collation_database              | cp1251_general_ci           |
| collation_server                | cp1251_general_ci           |
| max_connections                 | 100                         |
| max_user_connections            | 0                           |
debian:/etc/mysql# 

3) check it another way:
debian:/etc/mysql# echo "show variables" | mysql | egrep "connection|collation"
character_set_connection        latin1
collation_connection    latin1_swedish_ci
collation_database      cp1251_general_ci
collation_server        cp1251_general_ci
max_connections 100
max_user_connections    0
debian:/etc/mysql#

You can see, both results are different (character_set_connection and collation_connection options). But judging on scripts behavior, character_set_connection = latin1 and collation_connection = latin1_swedish_ci are actually used.
[15 Dec 2006 15:43] MySQL Verification Team
Thank you for the bug report. Could you please issue:

echo "show global variables" | mysql | egrep "connection|collation"

and compare with the mysqladmin output. Thanks in advance.
[15 Dec 2006 19:48] Yury Levin
Here it is:

debian:/# echo "show global variables" | mysql | egrep "connection|collation"
character_set_connection        cp1251
collation_connection    cp1251_general_ci
collation_database      cp1251_general_ci
collation_server        cp1251_general_ci
max_connections 100
max_user_connections    0
debian:/#

How to see global variables with mysqladmin?
[16 Dec 2006 12:47] MySQL Verification Team
Yury,

are you connected as root user?
if so this is expected behaviour. init_connect don't have any affect for users that have SUPER privilege.
Please connect to MySQL server as user that doesn't have SUPER privilege and try again.
[25 Dec 2006 10:54] Yury Levin
Yes, it works under non-root user. Thanks. Now I'll know environment of common users.

But I still have a question why results (with mysql and mysqladmin) are various if I run them as a root? If init-string does not affect root user, I should see the same values both times, but they are different.
[28 Dec 2006 7:49] Sveta Smirnova
Please read carefully in mysqladmin manual http://dev.mysql.com/doc/refman/5.0/en/mysqladmin.html what command `mysqladmin variables` returns
[28 Jan 2011 13:55] Artur Wosinski
hah. :| shame on me..
it`s a feature described in docs..