的Rails 3:更改字符集和现有的MySQL数据库
问题描述:
的核对是否有可能使用Rails迁移或其他选项更改现有的MySQL数据库的字符集和校对规则?!的Rails 3:更改字符集和现有的MySQL数据库
最初配置数据库字符集&排序规则的最佳方法是什么?
答
本地查询可以在轨道执行迁移:
def self.up
execute "ALTER DATABASE `#{ActiveRecord::Base.connection.current_database}` CHARACTER SET charset_here COLLATE collation_here;"
end
而对于初始配置,你可以预先定义的字符集和整理你的database.yml
文件,如:
production:
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_unicode_ci
链接已损坏,ca n您提供有关此迁移,请其他信息? – damoiser