简体   繁体   English

mysql utf-8支持

[英]mysql utf-8 support

when I create a new table, it always is 'latin-swedish-ci' by default. 创建新表时,默认情况下始终为“ latin-swedish-ci”。 my goal is that this table can store utf-8 text. 我的目标是该表可以存储utf-8文本。 I tried this way, give me error . 我这样尝试过,给我错误。

cd C:\mysql-5.5.14-winx64\bin
mysqld --standalone --console --default-storage-engine=InnoDB --default-character-set=utf8
 [ERROR] mysqld: unknown variable 'default-character-set=utf8'

Your Database probably has the default charset on latin1 and default collation set to latin1-swedish-ci and so altering the table should help 您的数据库可能在latin1上具有默认字符集,并且默认排序规则设置为latin1-swedish-ci,因此更改表应该会有所帮助

http://dev.mysql.com/doc/refman/5.1/en/alter-database.html http://dev.mysql.com/doc/refman/5.1/en/alter-database.html

ALTER DATABASE `MyDatabaseName` 
CHARACTER SET utf8
COLLATE utf8_general_ci;

You can always specify column encodings/collations within CREATE TABLE statement. 您始终可以在CREATE TABLE语句中指定列编码/排序规则。 This has additional benefit of making your data structure more portable in case you ever need to move it to another server. 如果您需要将数据结构移动到另一台服务器,这还具有使数据结构更具可移植性的额外好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM