Mysql default characters set and collation

Support/Development for PHP
nobody
Forum Regular
Forum Regular
Posts: 349
Joined: Sun Mar 29, 2009 6:52 pm

Mysql default characters set and collation

Unread post by nobody »

I really don't understand why mysql default charset is the swedish one.
When this have proved to cause in many cases many problems or issues.

I wish to make my mysql by default using utf8. And especially when creating new databases to set the collation as utf8.

Now I read an official mysql documentation but got more confused. Off course this happens because of my poor knowledge in databases.

But they suggest under mysqld section to add these lines in my.cnf

> skip-character-set-client-handshake
> collation_server=utf8_unicode_ci
> character_set_server=utf8

Anyone who has done such changes and wants to share his knowledge ?
Also if I enter these lines will there be any problem with the current databases set in different charsets ?
Hello IT.
Phone : Blah Blah ....
Have you tried turning it on and off again ?
Phone : Blah Blah ....
....
I'm sorry, are you from the Past ?!
http://www.youtube.com/watch?v=-E4fm4Wqego
Highland
Forum Regular
Forum Regular
Posts: 674
Joined: Mon Apr 10, 2006 12:55 pm

Re: Mysql default characters set and collation

Unread post by Highland »

If you're running an older database or application it's likely that the tables were created using latin1_swedish_ci as your character set. There's nothing wrong with that but most web pages now use UTF8 which can cause database issues with some odd characters.

Changing the my.cnf setting changes your default character set but will NOT automatically convert your latin tables to UTF8. You will have to do that manually. I suggest using phpmyadmin to do this. Be sure to edit the collation for the table (under Operations) as well as all your fields. Remember that if you have character problems now you might want to dump your table as-is and reimport afterwards.

As a side note, unless you need international characters, utf8_general_ci is faster than utf8_unicode_ci
"Its not a mac. I run linux... I'm actually cool." - scott
Post Reply