I am running this on a Windows 7 (64 bit) machine. I installed RoR using the one-click installer. I've updated my database.yml file to use mysql2:
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: blog_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: blog_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
I added this line to my Gemfile (per the tutorial video):
gem 'mysql2', :group => :production
Then:
gem install mysql2
which succeeds. Then:
bundle install
Which also succeeds, but mysql2 is not listed.
Then:
rake db:create
which gives this error:
"rake aborted! Please install the mysql2 adapter: gem install activerecord-mysql2-adapter
(my sql2 is not part of the bundle. Add it to Gemfile.) Tasks: TOP => db:create (See full trace by running task with --trace)"
bundle show mysql2
Gives this error: "Could not find gem 'mysql2' in the current bundle."
What am I missing to get mysql2 going?
Go to your app
Add this line
gem 'mysql2'
在rake db:create
之前运行bundle install
(在gem install mysql2
)
Similar issue was resolved for me after
After all that mysql2 appeared in list of gems after command "bundle install", I was able to run "rake db:create" successfully, started redmine x64 windows on x64 ruby 2.0 with x64 mysql on webrick, going on with configuring on some production server.
===============
An update
I have to precise that besides installing both mysql and mysql2 I created file Gemfile.local in redmine application top directory which probably made the trick with bundler. So I would recommend to replace the last step with:
I saw another answer that recommends to add mysql2 gem to Gemfile, but for me mysql2 was already included in Gemfile but has appeared in bundler output after adding to Gemfile.local only.
I'm leaving both solutions if I'm wrong and the trick was done by mysql gem installed together with mysql2, unfortunatelly I cannot remove/reinstall all from scratch now to test that for sure, I will update when I'm able to do so, hope all this will save some time to someone.
My Gemfile.local file contents is:
---8<---
gem "mysql2", "~> 0.3.11"
gem "eventmachine"
gem "thin"
---8<---
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.