在Windows中运行rake db:migrate时发生mysql错误 [英] mysql error while running rake db:migrate in Windows

查看:87
本文介绍了在Windows中运行rake db:migrate时发生mysql错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,我将数据库从sqlite3切换到mysql.所有配置均正确完成,但是在Windows计算机上运行rake db:migrate时出现错误.

I am working on a Project where i switched my database from sqlite3 to mysql.All configurations is done properly,but i am getting error while i am running rake db:migrate on Windows machine.

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的我的database.yml文件

this is my database.yml file for windows

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

default: &default adapter: mysql2 encoding: utf8 pool: 5 username: root password: **** socket: /var/run/mysqld/mysqld.sock development: <<: *default database: hrms_development test: <<: *default database: hrms_test production: <<: *default database: hrms_production username: hrms password: <%= ENV['HRMS_DATABASE_PASSWORD'] %>

是正确的...还是我需要添加一些其他设置??????????????

is it correct...or i need to include some more settings??????????????

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

* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

提供的配置选项: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include = $ {opt-dir}/include --with-opt-lib --without-opt-lib = $ {opt-dir}/lib --with-make-prog --with-make-prog --srcdir =. --curdir --ruby = D:/Ruby21-x64/bin/ruby --with-mysql-dir --with-mysql-include --without-mysql-include = $ {mysql-dir}/include --with-mysql-lib --without-mysql-lib = $ {mysql-dir}/lib

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=D:/Ruby21-x64/bin/ruby --with-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib

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

To see why this extension failed to compile, please check the mkmf.log which can be found here:

D:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/mysql2-0.4.5/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

extconf failed, exit code 1

推荐答案

有两个原因;

  1. 您没有在database.yml中正确指定适配器
  2. 您错过了将必要的gem添加到gem文件的过程.

请分享您的rails版本,您可以尝试使用"mysql"作为适配器.

Please share your rails version and can you try with 'mysql' as adapter.

这篇关于在Windows中运行rake db:migrate时发生mysql错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆