Mysql - 将数据库、表更改为utf8
In /etc/my.cnf the following has been added
character-set-server=utf8
collation-server=utf8_general_ci
但是对于添加上述之前创建的数据库和表如何将数据库和表转换为带有排序规则设置的utf8
In /etc/my.cnf the following has been added
character-set-server=utf8
collation-server=utf8_general_ci
But for the database and tables created before adding the above how to convert the database and tables to utf8 with collation settings
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,数据库字符集和表字符集只是默认值(它们不会直接影响任何内容)。您需要将每一列修改为正确的字符集。 PHPMyAdmin 将为您执行此操作(只需编辑列,然后更改字符集)。如果您想要执行原始 SQL,您需要知道列定义(
SHOW CREATE TABLE foo
将向您显示定义)。然后,您可以使用ALTER TABLE
更改定义。要更改表的默认字符集:
要更改具有定义 `foo VARCHAR(128) CHARACTER SET 'foo' COLLATE 'foo'`` 的列的字符集:
Well, the database character set and table character set are just defaults (they don't affect anything directly). You'd need to modify each column to the proper charset. PHPMyAdmin will do this for you (just edit the column, then change the character set). If you want to do raw SQL, you'll need to know the column definition (
SHOW CREATE TABLE foo
will show you the definition). Then, you can useALTER TABLE
to change the definition.To change the default charset for a table:
To change the charset of a column with the definition `foo VARCHAR(128) CHARACTER SET 'foo' COLLATE 'foo'``:
https://serverfault.com/ questions/65043/alter-charset-and-collation-in-all-columns-in-all-tables-in-mysql
并且:
http://www.mysqlperformanceblog.com/2009/03/17/converting-character-sets/
https://serverfault.com/questions/65043/alter-charset-and-collation-in-all-columns-in-all-tables-in-mysql
And:
http://www.mysqlperformanceblog.com/2009/03/17/converting-character-sets/