diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index b014929f480f19ab187345fab1cdc2b1fafe6659..854fae4f15f7c8a45ea0acbbdd4a44fa03dd2ae3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2094,11 +2094,11 @@ static int init_common_variables(const char *conf_file_name, int argc,
     }
     default_charset_info= default_collation;
   }
-  global_system_variables.character_set_server= default_charset_info;
-  global_system_variables.character_set_database= default_charset_info;
+  global_system_variables.collation_server= default_charset_info;
+  global_system_variables.collation_database= default_charset_info;
+  global_system_variables.collation_connection= default_charset_info;
   global_system_variables.character_set_results= default_charset_info;
   global_system_variables.character_set_client= default_charset_info;
-  global_system_variables.collation_connection= default_charset_info;
 
   if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
     return 1;
@@ -4825,11 +4825,11 @@ static void mysql_init_variables(void)
 
 
   /* Set default values for some option variables */
-  global_system_variables.character_set_server= default_charset_info;
-  global_system_variables.character_set_database= default_charset_info;
+  global_system_variables.collation_server= default_charset_info;
+  global_system_variables.collation_database= default_charset_info;
+  global_system_variables.collation_connection= default_charset_info;
   global_system_variables.character_set_results= default_charset_info;
   global_system_variables.character_set_client= default_charset_info;
-  global_system_variables.collation_connection= default_charset_info;
   global_system_variables.table_type=   DB_TYPE_MYISAM;
   global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
   global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 194d91d2c4fa8ed12c6dce18445b174fdcbebf61..199a398b4976733479c88c7f3ce51bfd13cdd3db 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -116,6 +116,8 @@ sys_var_character_set_client  sys_character_set_client("character_set_client");
 sys_var_character_set_connection  sys_character_set_connection("character_set_connection");
 sys_var_character_set_results sys_character_set_results("character_set_results");
 sys_var_collation_connection sys_collation_connection("collation_connection");
+sys_var_collation_database sys_collation_database("collation_database");
+sys_var_collation_server sys_collation_server("collation_server");
 sys_var_bool_ptr	sys_concurrent_insert("concurrent_insert",
 					      &myisam_concurrent_insert);
 sys_var_long_ptr	sys_connect_timeout("connect_timeout",
@@ -381,6 +383,8 @@ sys_var *sys_variables[]=
   &sys_character_set_connection,
   &sys_character_set_results,
   &sys_collation_connection,
+  &sys_collation_database,
+  &sys_collation_server,
   &sys_concurrent_insert,
   &sys_connect_timeout,
   &sys_default_week_format,
@@ -509,6 +513,8 @@ struct show_var_st init_vars[]= {
   {sys_character_set_connection.name,(char*) &sys_character_set_connection,SHOW_SYS},
   {sys_character_set_results.name,(char*) &sys_character_set_results, SHOW_SYS},
   {sys_collation_connection.name,(char*) &sys_collation_connection, SHOW_SYS},
+  {sys_collation_database.name,(char*) &sys_collation_database,     SHOW_SYS},
+  {sys_collation_server.name,(char*) &sys_collation_server,         SHOW_SYS},
   {sys_concurrent_insert.name,(char*) &sys_concurrent_insert,       SHOW_SYS},
   {sys_connect_timeout.name,  (char*) &sys_connect_timeout,         SHOW_SYS},
   {"datadir",                 mysql_real_data_home,                 SHOW_CHAR},
@@ -1422,20 +1428,19 @@ CHARSET_INFO **
 sys_var_character_set_server::ci_ptr(THD *thd, enum_var_type type)
 {
   if (type == OPT_GLOBAL)
-    return &global_system_variables.character_set_server;
+    return &global_system_variables.collation_server;
   else
-    return &thd->variables.character_set_server;
+    return &thd->variables.collation_server;
 }
 
 
 void sys_var_character_set_server::set_default(THD *thd, enum_var_type type)
 {
  if (type == OPT_GLOBAL)
-   global_system_variables.character_set_server= default_charset_info;
+   global_system_variables.collation_server= default_charset_info;
  else
  {
-   thd->variables.character_set_server= (global_system_variables.
-					 character_set_server);
+   thd->variables.collation_server= global_system_variables.collation_server;
    thd->update_charset();
  }
 }
@@ -1445,19 +1450,19 @@ CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
 						       enum_var_type type)
 {
   if (type == OPT_GLOBAL)
-    return &global_system_variables.character_set_database;
+    return &global_system_variables.collation_database;
   else
-    return &thd->variables.character_set_database;
+    return &thd->variables.collation_database;
 }
 
 
 void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
 {
  if (type == OPT_GLOBAL)
-    global_system_variables.character_set_database= default_charset_info;
+    global_system_variables.collation_database= default_charset_info;
   else
   {
-    thd->variables.character_set_database= thd->db_charset;
+    thd->variables.collation_database= thd->db_charset;
     thd->update_charset();
   }
 }
@@ -1498,6 +1503,77 @@ void sys_var_collation_connection::set_default(THD *thd, enum_var_type type)
  }
 }
 
+bool sys_var_collation_database::update(THD *thd, set_var *var)
+{
+  if (var->type == OPT_GLOBAL)
+    global_system_variables.collation_database= var->save_result.charset;
+  else
+  {
+    thd->variables.collation_database= var->save_result.charset;
+    thd->update_charset();
+  }
+  return 0;
+}
+
+
+byte *sys_var_collation_database::value_ptr(THD *thd, enum_var_type type,
+					      LEX_STRING *base)
+{
+  CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
+		  global_system_variables.collation_database :
+		  thd->variables.collation_database);
+  return cs ? (byte*) cs->name : (byte*) "NULL";
+}
+
+
+void sys_var_collation_database::set_default(THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+   global_system_variables.collation_database= default_charset_info;
+ else
+ {
+   thd->variables.collation_database= (global_system_variables.
+					 collation_database);
+   thd->update_charset();
+ }
+}
+
+
+bool sys_var_collation_server::update(THD *thd, set_var *var)
+{
+  if (var->type == OPT_GLOBAL)
+    global_system_variables.collation_server= var->save_result.charset;
+  else
+  {
+    thd->variables.collation_server= var->save_result.charset;
+    thd->update_charset();
+  }
+  return 0;
+}
+
+
+byte *sys_var_collation_server::value_ptr(THD *thd, enum_var_type type,
+					      LEX_STRING *base)
+{
+  CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
+		  global_system_variables.collation_server :
+		  thd->variables.collation_server);
+  return cs ? (byte*) cs->name : (byte*) "NULL";
+}
+
+
+void sys_var_collation_server::set_default(THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+   global_system_variables.collation_server= default_charset_info;
+ else
+ {
+   thd->variables.collation_server= (global_system_variables.
+					 collation_server);
+   thd->update_charset();
+ }
+}
+
 
 bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
 {
diff --git a/sql/set_var.h b/sql/set_var.h
index 9c9ad0719670a480de7ba480854b06b76fbb6bb2..812bd6c9420341d9fd5d38ba2f54a83a02034e45 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -523,6 +523,23 @@ class sys_var_collation_connection :public sys_var_collation
   byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 };
 
+class sys_var_collation_server :public sys_var_collation
+{
+public:
+  sys_var_collation_server(const char *name_arg) :sys_var_collation(name_arg) {}
+  bool update(THD *thd, set_var *var);
+  void set_default(THD *thd, enum_var_type type);
+  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+};
+
+class sys_var_collation_database :public sys_var_collation
+{
+public:
+  sys_var_collation_database(const char *name_arg) :sys_var_collation(name_arg) {}
+  bool update(THD *thd, set_var *var);
+  void set_default(THD *thd, enum_var_type type);
+  byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+};
 
 class sys_var_key_buffer_size :public sys_var
 {
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index dc6e791c4be5ba97927dadb2b455454fdbd97e83..fa4f08b5f14359e653fd7eec30e13b3a04111f50 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2328,7 +2328,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
   DBUG_ENTER("mysql_create_index");
   bzero((char*) &create_info,sizeof(create_info));
   create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.table_charset= thd->variables.character_set_database;
+  create_info.table_charset= thd->variables.collation_database;
   DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
 				&create_info, table_list,
 				fields, keys, drop, alter, 0, (ORDER*)0, FALSE,
@@ -2345,7 +2345,7 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
   DBUG_ENTER("mysql_drop_index");
   bzero((char*) &create_info,sizeof(create_info));
   create_info.db_type=DB_TYPE_DEFAULT;
-  create_info.table_charset= thd->variables.character_set_database;
+  create_info.table_charset= thd->variables.collation_database;
   DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
 				&create_info, table_list,
 				fields, keys, drop, alter, 0, (ORDER*)0, FALSE,
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index e549b875bcb8068034c2b11783d361530ce8f41c..d954d4dc22d67fa7db077332267ffa523ccaea1b 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -107,7 +107,7 @@ THD::THD():user_time(0), is_fatal_error(0),
   variables.pseudo_thread_id= 0;
   file_id = 0;
   warn_id= 0;
-  db_charset= global_system_variables.character_set_database;
+  db_charset= global_system_variables.collation_database;
   mysys_var=0;
 #ifndef DBUG_OFF
   dbug_sentry=THD_SENTRY_MAGIC;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index e8c09b326a520befeb17f2740ac321e6b2234702..e0358fc25e9b24f37a3454b4b51cab516aacebe8 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -401,10 +401,13 @@ struct system_variables
   my_bool new_mode;
   my_bool old_passwords;
   
-  CHARSET_INFO	*character_set_server;
-  CHARSET_INFO	*character_set_database;
+  /* Only charset part of these variables is sensible */
   CHARSET_INFO 	*character_set_client;
   CHARSET_INFO  *character_set_results;
+  
+  /* Both charset and collation parts of these variables are important */
+  CHARSET_INFO	*collation_server;
+  CHARSET_INFO	*collation_database;
   CHARSET_INFO  *collation_connection;
 };
 
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 0d0d1d897d0f95ab0c60278b5198049bbe08a179..2b42c2c9a5b52e3324398af7459f7acab5b8a3a7 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -62,7 +62,7 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
     ulong length;
     CHARSET_INFO *cs= (create && create->table_charset) ? 
 		     create->table_charset :
-		     thd->variables.character_set_database;
+		     thd->variables.collation_database;
     length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", cs->csname,cs->name));
 
     /* Error is written by my_write */
@@ -99,7 +99,7 @@ static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
   uint nbytes;
 
   bzero((char*) create,sizeof(*create));
-  create->table_charset= global_system_variables.character_set_database;
+  create->table_charset= global_system_variables.collation_database;
   if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0)
   {
     IO_CACHE cache;
@@ -288,8 +288,8 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
   {
     thd->db_charset= (create_info && create_info->table_charset) ?
 		     create_info->table_charset : 
-		     global_system_variables.character_set_database;
-    thd->variables.character_set_database= thd->db_charset;
+		     global_system_variables.collation_database;
+    thd->variables.collation_database= thd->db_charset;
   }
 
   mysql_update_log.write(thd,thd->query, thd->query_length);
@@ -632,8 +632,8 @@ bool mysql_change_db(THD *thd, const char *name)
   load_db_opt(thd, path, &create);
   thd->db_charset= create.table_charset ?
 		   create.table_charset :
-		   global_system_variables.character_set_database;
-  thd->variables.character_set_database= thd->db_charset;
+		   global_system_variables.collation_database;
+  thd->variables.collation_database= thd->db_charset;
   DBUG_RETURN(0);
 }
 
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 771b1ab11d699a4e783f5c1b82c997fe2825511c..60e0a7c7e94344ea69ff8b9364f41490862f936f 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -224,7 +224,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   info.handle_duplicates=handle_duplicates;
   info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
 
-  READ_INFO read_info(file,tot_length,thd->variables.character_set_database,
+  READ_INFO read_info(file,tot_length,thd->variables.collation_database,
 		      *field_term,*ex->line_start, *ex->line_term, *enclosed,
 		      info.escape_char, read_file_from_client, is_fifo);
   if (read_info.error)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 2a35c03f3b40eda42f4fd5099b5ccd622f7478f9..d9d79f03c3f7cc8857be0b304804c8f2d1878b3e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -914,7 +914,7 @@ create:
 	  bzero((char*) &lex->create_info,sizeof(lex->create_info));
 	  lex->create_info.options=$2 | $4;
 	  lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type;
-	  lex->create_info.table_charset= thd->variables.character_set_database;
+	  lex->create_info.table_charset= thd->variables.collation_database;
 	  lex->name=0;
 	}
 	create2
@@ -1632,7 +1632,7 @@ alter:
 	  lex->select_lex.db=lex->name=0;
 	  bzero((char*) &lex->create_info,sizeof(lex->create_info));
 	  lex->create_info.db_type= DB_TYPE_DEFAULT;
-	  lex->create_info.table_charset= thd->variables.character_set_database;
+	  lex->create_info.table_charset= thd->variables.collation_database;
 	  lex->create_info.row_type= ROW_TYPE_NOT_USED;
           lex->alter_keys_onoff=LEAVE_AS_IS;
           lex->simple_alter=1;
@@ -4723,7 +4723,7 @@ option_value:
 	  THD *thd= YYTHD;
 	  LEX *lex= Lex;
 	  $2= $2 ? $2: global_system_variables.character_set_client;
-	  lex->var_list.push_back(new set_var_collation_client($2,thd->variables.character_set_database,$2));
+	  lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
 	}
 	| NAMES_SYM charset_name_or_default opt_collate
 	{