Bug #21551 mysql cmdline client remembers current database but not the charset
Submitted: 9 Aug 2006 19:17 Modified: 10 Sep 2006 2:30
Reporter: Andrey Hristov Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0, probably 4.1 OS:
Assigned to: CPU Architecture:Any

[9 Aug 2006 19:17] Andrey Hristov
Description:
The mysql cmd line client remembers the current database, so when reconnecting if the socket is closed for some reason, server restart or the connection has timed out, it cannot connect. This can be reproduced if the characters from charset different than the standard one are used. In the example I switch to utf8, which is usual, and create a database with cyrillic name.
mysql> create database база_данни_на_кирилица;
Query OK, 1 row affected (0.00 sec)

mysql> show databases like "база%";
+-------------------------------------------+
| Database (база%)                      |
+-------------------------------------------+
| база_данни_на_кирилица |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> use база_данни_на_кирилица;
Database changed

--here the connection times out and when issuing statement it should reconnect
mysql> select 1;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 1049 (42000): Unknown database 'база_данни_на_кири'
ERROR:
Can't connect to the server

--but it can't because the charset is not set to utf8 as it was

The problem probably exists in 4.1 too. 5.1 could be a bit different, so please check with it too.

How to repeat:
create database база_данни_на_кирилица;
show databases like "база%";
use база_данни_на_кирилица;
kill kill connection_id();
select 1;
[10 Sep 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".