How do i Setup utf-8 as standard character set for a mysql server?
do i have to recompile it?
i figured out diffent ways of setting the character set values see
http://dev.mysql.com/doc/refman/5.5/en/charset.html
but starting it with other values or my.cnf settings changed nothing. Because if i do:
sudo mysqld --verbose --help | grep charact
it always answers me latin1 as standard charset. the system is ubuntu lts server with a standard my开发者_如何学JAVAsql install.
Solution:
add this into my.cnf:
[mysqld]
character-set-server=utf8
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8
[mysql]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqladmin]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlcheck]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqldump]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlimport]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
[mysqlshow]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
#end
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
skip-character-set-client-handshake
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
UPDATE: Nowadays you should probably use utf8mb4.
Create file /etc/mysql/conf.d/mysqld.cnf with contents:
[mysqld]
character-set-server = utf8
collation-server = utf8_unicode_ci
If you omit collation-server it should be set up to utf8_general_ci.
I've tested this configuration with MySQL 5.6 on Ubuntu 15.04.
精彩评论