views:

26

answers:

1

currently we are using following commands in PHP to set the character set to UTF8 in our application.

Since this is a bit of overhead, we'd like to set this as the default setting in mysql. Can we do this in /etc/my.cnf or in another location?

SET NAMES 'utf8'
SET CHARACTER SET utf8

I've looked for a default charset in /etc/my.cnf but there's nothing there about charsets.

Thanks a lot for helping out!

at this point, I did the following to set the mysql charset and collation variables to UTF8:

skip-character-set-client-handshake
character_set_client=utf8
character_set_server=utf8

is that a correct way to handle this?

+2  A: 

To set the default to UTF-8, you want to add the following to my.cnf

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


[mysqld]
default-character-set = utf8    
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

If you want to change the character set for an existing DB, let me know... your question didn't specify it directly so I am not sure if that's what you want to do.

NinjaCat
thanks, I solved it this way, can you let me know if that's also a correct way to handle this? skip-character-set-client-handshakecharacter_set_client=utf8character_set_server=utf8
Jorre