Mahesh Sharma
Mahesh Sharma

Reputation: 221

mysql error while running rake db:migrate in Windows

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)

this is my database.yml file for windows

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 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.

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

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

extconf failed, exit code 1

Upvotes: 1

Views: 319

Answers (1)

Rajeev G
Rajeev G

Reputation: 16

There can be two reasons;

  1. You did not specify the adapter properly in database.yml
  2. You missed to add necessary gem to gem file.

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

Upvotes: 0

Related Questions