Thursday 15 April 2010

hibernate - Set CENTOS 6 mysql character sets to UTF8 -



hibernate - Set CENTOS 6 mysql character sets to UTF8 -

i have website, , realised when re-create characters(*,' " - _) specific applications microsoft word, search box on website, returns error:

error org.hibernate.util.jdbcexceptionreporter - illegal mix of collations (latin1_swedish_ci,implicit) , (utf8_general_ci,coercible) operation 'like'

so went check out database , wanted see if database used utf-8.

mysql> show variables '%character%'; +--------------------------+----------------------------+ | variable_name | value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) mysql> show variables '%collation%'; +----------------------+-------------------+ | variable_name | value | +----------------------+-------------------+ | collation_connection | utf8_general_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | +----------------------+-------------------+

as can see, database using latin1 , wanted set utilize utf8. firstly, i'm on centos 6.2 server , file my.cnf file resides in /etc/my.cnf , file follows under [mysqld]:

[mysqld] local-infile=0 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # disabling symbolic-links recommended prevent assorted security risks symbolic-links=0 init_connect ='set names utf8' character_set_server = utf8 collation_server = utf8_general_ci

p.s not worried [client] section since shows uses utf8 under value of character_set_client. the issue: although i've tried set server in my.cnf file (and closed file, shutdown tomcat , restarted tomcat). nil changing. , when run first query displayed, still shows character_set_server still using latin1

although restarting tomcat didn't have effect, had restart 'mysql' in order changes take place. you'd have stop main server first (in case stop tomcat) , restart mysql , start tomcat again. after, in mysql if type: show variables %character%; should see database datatype utf-8 , if type: show variables %collation% should see database collation info type should utf-8_general_ci.

mysql hibernate utf-8 centos6 my.cnf

No comments:

Post a Comment