Bug #13144 Add a PERMANENT default overall charset option
Submitted: 13 Sep 2005 16:46 Modified: 25 Sep 2005 8:42
Reporter: Renich Bon Ciric Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:4.1.12 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[13 Sep 2005 16:46] Renich Bon Ciric
Description:
I would like you to add an OVERALL charset option.

The "default-character-set" option under the [mysqld] section, in the "my.cnf" file does NOT change:
- character_set_connection
- character_set_client
- character_set_results

I tried adding "default-character-set" to the [mysql] section and it "modified" this values, but it only apears so, beacause it keeps using latin1 as character_set_connection, character_set_client and character_set_results.

How to repeat:
Start mysql in a fedora core 4 OS with the following my.cnf config

##############################################################################################################
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set=utf8

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysql]
default-character-set=utf8

##############################################################################################################

Now, try any query using php with utf-8 charset

##############################################################################################################

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PHP UTF-8 Query Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>

<?php

// Connect to db (add your own user and password)
$link = mysqli_connect('localhost','user','password','test');

// Create tables
// $query0 = "SET NAMES utf8;"; // We are NOT SUPOSED to use this
$query1 = "CREATE TABLE `Asistente de Direccion` ( `ID` smallint(5) unsigned NOT NULL ) TYPE = MYISAM CHARACTER SET utf8;";
$query2 = "CREATE TABLE `Asistente de Dirección` ( `ID` smallint(5) unsigned NOT NULL ) TYPE = MYISAM CHARACTER SET utf8;";
$query3 = "INSERT INTO `Asistente de Direccion` VALUES('1');";
$query4 = "INSERT INTO `Asistente de Dirección` VALUES('1');";
$query5 = "SELECT * FROM `Asistente de Direccion`;";
$query6 = "SELECT * FROM `Asistente de Dirección`;";

// $result0 = mysqli_query($link,$query0) or die("Error in \$query0 <br>\n" . mysqli_error($link) . "<br> \n");
$result1 = mysqli_query($link,$query1) or die("Error in \$query1 <br>\n" . mysqli_error($link) . "<br> \n");
$result2 = mysqli_query($link,$query2) or die("Error in \$query2 <br>\n" . mysqli_error($link) . "<br> \n");

// Insert some info
$result3 = mysqli_query($link,$query3) or die("Error in \$query3 <br>\n" . mysqli_error($link) . "<br> \n");
$result4 = mysqli_query($link,$query4) or die("Error in \$query4 <br>\n" . mysqli_error($link) . "<br> \n");

// Get table's info
$result5 = mysqli_query($link,$query5) or die("Error in \$query5 <br>\n" . mysqli_error($link) . "<br> \n");
$result6 = mysqli_query($link,$query6) or die("Error in \$query6 <br>\n" . mysqli_error($link) . "<br> \n");

// Print info
while ( $data = mysqli_fetch_assoc($result5) ) {
	print "<pre>";
	print_r($data);
	print "</pre>";
}

while ( $data1 = mysqli_fetch_assoc($result6) ) {
	print "<pre>";
	print_r($data1);
	print "</pre>";
}

mysqli_close($link);

?>

</body>
</html>

##############################################################################################################

Make shure that if you copy and paste the text, u use UTF-8 characters & encoding... 

Suggested fix:
make the "set-default-charset" really work for ALL the charset variables.
[25 Sep 2005 8:42] Sergei Golubchik
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Additional info:

See bug#9948