Bug #35357 character_set_database does not effects CREATE DATABASE without character set
Submitted: 18 Mar 2008 5:14 Modified: 18 Jan 2018 13:11
Reporter: Rizwan Maredia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.1.22, 5.1.23 OS:Windows
Assigned to: CPU Architecture:Any
Tags: character_set_database, create database

[18 Mar 2008 5:14] Rizwan Maredia
Description:
character_set_database does not effects databases which are created without specifying characater set clause. The value is taken from character_set_server. Although this thing is well documented but the purpose of setting character_set_database is thus of no value.

How to repeat:
Sample test in mysql test environment

Sample Code:
SET @@session.character_set_server = utf8;
SET @@session.character_set_database = latin5;
CREATE DATABASE db1;
SHOW CREATE DATABASE db1;
 
Output:
SET @@session.character_set_server = utf8;
SET @@session.character_set_database = latin5;
CREATE DATABASE db1;
SHOW CREATE DATABASE db1;
Database	Create Database
db1	CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8 */

Suggested fix:
Character_set_database should be used for database that do not specify a character set. This looks more logical than using character_set_server instead. If there is no purpose of setting this variable then it should be readonly.
[18 Mar 2008 10:43] Valeriy Kravchuk
Thank you for a problem report.
[7 Aug 2008 6:47] Konstantin Osipov
WL#3811 Deprecate GLOBAL @@collation_database, @@character_set_database; assignment of SESSION counterparts
[27 Jan 2011 12:09] Ståle Deraas
Probably a charset bug
[18 Jan 2018 13:11] Erlend Dahl
[2 Jan 2018 0:16] Xing Z Zhang 

Fixed in 5.6 by implementation of WL#3811. Character_set_database is deprecated.