仅在Grails数据库表中使用UTF-8 [英] UTF-8 only in Grails database tables
问题描述
从自动生成的数据库定义:
ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1;
请注意latin1部分。
大多数MySQL安装默认为latin1,所以如果没有其他指示,驱动程序将会默认值。例如:
jdbc:mysql://在连接URL中预先填充charset指令就足够了。 localhost / databaseName?useUnicode = yes& characterEncoding = UTF-8
连接器JAR必须是版本5(3.x将不起作用)。
When using Grails 1.0.4 together with a MySQL the charsets of the auto-generated database tables seem to default to ISO-8859-1. I'd rather have everything stored as pure UTF-8. Is that possible?
From the auto-generated database definitions:
ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Note the "latin1" part.
Most MySQL installations default to latin1, so if not instructed otherwise, the driver will go by the default values. It should suffice to prepend the charset directives in the connection URL, for example:
jdbc:mysql://localhost/databaseName?useUnicode=yes&characterEncoding=UTF-8
For this to work, the MySQL Connector JAR must be of version 5 (3.x will not work).
Source: MySQL Reference manual: Using Character Sets and Unicode
这篇关于仅在Grails数据库表中使用UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!