setting up default character set/collation
Posted by: bijan hoomand
Date: October 25, 2005 11:05AM

Hey ppl, how're ya?

I just learned how to use charsets and collations. My language is Farsi and since I was using previous versions of MySQL, I had no problem. But upgrading to 4.1, I notice that character "ف" is not displayed the way it should be. After reading chapter 10 of your manual, I sent this query after connecting to my database in PHP, and I have no problem:

$res = mysql_query("SET NAMES 'utf8'");
if ( !$res )
	print "<pre>" . mysql_error() . "</pre>";

The thing is that I really do not wana send it in my PHP code, since I have some scritps that I'm not allowed to modify, so, I tried starting mysqld with the default-character-set option, just like:

mysqld_safe  --default-character-set=utf8            --default-collation=utf8_general_ci &

and it really works fine. I even checked the Server Variable and Settings in phpMyAdmin and everything is set to utf8. But you know what? My code still doesn't work if I remove the first code that I wrote in here, I mean if I don't send that query (SET NAMES 'utf8'), I was wondering why? I mean it's working, as the server variables show, but then they have no effect. What should I do?!


PS: If I want the default character sets be included in run time that I don't have to shutdown my server whenever I restart my computer and then run it again with default values, can I write something like this in ~/.my.cnf and then it works?


Options: ReplyQuote

Written By
setting up default character set/collation
October 25, 2005 11:05AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.