Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My mysql server's current server character set is latin1. My server is started on startup via rc.conf setting mysql_enable="YES". How to set my server to use utf8 as the server character set?

share|improve this question

2 Answers 2

From the manual,

Specify character settings at server startup. To select a character set and collation at server startup, use the --character-set-server and --collation-server options.

You include the following in /usr/local/etc/my.cnf

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci

(You could find samples of my.cnf in /usr/local/share/mysql)

More information on mysql

share|improve this answer
1  
/etc/mysql doesn't exist on FreeBSD –  User Sep 8 '12 at 2:43
    
@User that's a mistake, sorry. answer updated –  warl0ck Sep 8 '12 at 2:55
    
I'm trying this but for some reason mysql doesn't want to start when the file is there. If I rename the file then mysql starts fine. –  User Sep 8 '12 at 3:02

I edited /etc/rc.conf and added the mysql_args line below:

mysql_enable="YES"
mysql_args="--character-set-server=utf8"

This works and I can see the server character set is updated.

share|improve this answer
    
I'd prefer a config file based solution but this is working for now –  User Sep 8 '12 at 3:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.