Bug #9230 option so that [character_set|collation]_connection are auto-set to current ...
Submitted: 16 Mar 2005 19:40 Modified: 14 Dec 2010 20:05
Reporter: Matthew Lord Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Charsets Severity:S4 (Feature request)
Version:4.1.x OS:Any (all)
Assigned to: CPU Architecture:Any

[16 Mar 2005 19:40] Matthew Lord
Description:
It would be nice if there was a variable that would change the behavior so that the connection character set and collation were automatically set to whatever the current database has for it's
defaults.  This would be convienient when you work with databases of various character sets and
collations.

How to repeat:
N/A

Suggested fix:
Adding variables along the lines of --db-based-connection-character-set and --db-based-connection-collation that would change the default behavior as mentioned above.
[21 Oct 2010 8:46] Alexander Barkov
Starting from mysql-5.1 this can be done using --init-command parameter:

./mysql --init-command="set @@collation_connection=@@collation_database,@@character_set_results=@@character_set_database,@@character_set_client=@@character_set_database"  dbname
[14 Dec 2010 19:44] Valeriy Kravchuk
Bug #10186 was marked as a duplicate of this one.
[14 Dec 2010 20:05] Matthew Lord
How did this get closed?

1) --init-command doesn't do anything *automatically*.  
2) --init-command is a mysql cmd-line-client option

The idea was to specify a variable so that when you do this:
use foo;

The connection character set options are changed to the default ones for the foo
database.  This may not be possible but it's certainly not accomplished with the 
mysql binaries --init-command option.