在Windows

时间:2017-03-28 09:25:54

标签: mysql ruby-on-rails-4

我正在开发一个项目,我将数据库从sqlite3切换到mysql.All配置正确完成,但我在Windows机器上运行rake db:migrate时收到错误。

PS D:\workspace\hrms> rake db:migrate
rake aborted!
LoadError: Could not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that the adapter in config/datab
ase.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapte
r gem to the Gemfile.
D:/workspace/hrms/config/environment.rb:5:in `<top (required)>'
LoadError: cannot load such file -- mysql2
D:/workspace/hrms/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

这是我的windows的数据库.yml文件

默认值:&amp;默认值   适配器:mysql2   编码:utf8   游泳池:5   用户名:root   密码:****   socket:/var/run/mysqld/mysqld.sock 发展:   &lt;&lt ;: *默认   数据库:hrms_development 测试:   &lt;&lt ;: *默认   数据库:hrms_test 生产:   &lt;&lt ;: *默认   数据库:hrms_production   用户名:hrms   密码:&lt;%= ENV ['HRMS_DATABASE_PASSWORD']%&gt;

是正确的......或者我需要包含更多设置??????????????

* extconf.rb失败* 由于某些原因无法创建Makefile,可能缺少必要的 库和/或标题。检查mkmf.log文件以获取更多详细信息。你可以 需要配置选项。

提供配置选项:         --with-OPT-DIR         --without-OPT-DIR         --with-OPT-包括         --without-OPT-包括= $ {停用DIR} /包括         --with-OPT-LIB         --without-OPT-LIB = $ {选择-DIR} / lib目录         --with-MAKE-PROG         --without-MAKE-PROG         --srcdir =。         --curdir         --ruby = d:/ Ruby21-X64 /斌/红宝石         --with-mysql的-DIR         --with-mysql的,包括         --without MySQL的-包括= $ {的MySQL-DIR} /包括         --with-mysql的-LIB         --without MySQL的-LIB = $ {的MySQL-DIR} / lib中

要查看此扩展无法编译的原因,请查看mkmf.log,可在此处找到:

d:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/mysql2-0.4.5/mkmf.log

extconf失败,退出代码1

1 个答案:

答案 0 :(得分:0)

可能有两个原因;

  1. 您未在database.yml
  2. 中正确指定适配器
  3. 你错过了为gem文件添加必要的gem。
  4. 请分享你的rails版本,你可以试试'mysql'作为适配器。

相关问题