【发布时间】:2015-03-10 16:14:37
【问题描述】:
我有一个从 Github 克隆的 Ruby on Rails 4 应用程序,我正在尝试在开发环境中的 MacBook 上启动和运行。
最初应用程序抱怨找不到 MySQL,所以我做了brew install mysql。我现在有mysqld 使用用户名root 运行并且没有密码并且应用程序能够连接到它,所以我通过了第一个驼峰。
不过,该架构尚未在数据库中构建 - 我可以在 db/migrate/ 目录中看到大约 115 个文件,其名称类似于 004_make_unicode_fiendly.rb 和 016_add_asin_column.rb。
我尝试运行bundle exec rake db:migrate,但前三个迁移文件显然运行成功后出现错误:
Migration error: Unsupported database for migration to UTF-8 support
/Users/jon/work/amazing_app/db/migrate/004_make_unicode_friendly.rb:22:in `alter_database_and_tables_charsets'
/Users/jon/work/amazing_app/db/migrate/004_make_unicode_friendly.rb:3:in `up'
运行mysqladmin variables | grep utf8 显示:
| character_set_client | utf8
| character_set_connection | utf8
| character_set_database | utf8
| character_set_results | utf8
| character_set_server | utf8
| character_set_system | utf8
| collation_connection | utf8_general_ci
| collation_database | utf8_general_ci
| collation_server | utf8_general_ci
我的问题:为什么会出现迁移错误?
【问题讨论】:
-
您可以尝试运行 (bundle exec) rake db:create(如果尚未创建数据库),然后 rake db:reset?
-
另外,如果这不是解决方案,能否请您提供 004_make_unicode_friendly.rb 文件,以便我们进一步查看(github gist 或 pastebin)
-
谢谢 - 我刚刚按顺序发出了以下三个命令,现在似乎一切正常:
bundle exec rake db:createbundle exec rake db:resetbundle exec rake db:migrate
标签: mysql ruby-on-rails-4 rake bundler dbmigrate