大家好,我是 rails 新手。我安装的 rails 默认数据库是 sqlite3.但是我想用 mysql。于是百度了一下。 先安装了 mysql 的相关工具,server,client.
netstat -tap |grep mysql
tcp 0 0 localhost:mysql *:* LISTEN 11990/mysqld
rails new app -d mysql
rails generate controller Site index about help
错误:Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/root/railsspace/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
我的 Gemfile:
1 source 'https://rubygems.org'
4 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5 gem 'rails', '4.2.3'
6 # Use mysql as the database for Active Record
7 gem 'mysql2', '~> 0.4.1'
9 # Use SCSS for stylesheets
10 gem 'sass-rails', '~> 5.0'
11 # Use Uglifier as compressor for JavaScript assets
12 gem 'uglifier', '>= 1.3.0'
13 # Use CoffeeScript for .coffee assets and views
14 gem 'coffee-rails', '~> 4.1.0'
根据搜的各类帖子,貌似都没有解决掉问题。请问问题出现在哪里?