我正在研究Fedora19。
[root@localhost coffee]# ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
[root@localhost coffee]# rails -v
Rails 3.0.
这是我的Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
当我做rake db:migrate时,我收到了这个错误
[root@localhost coffee]# rake db:migrate
rake aborted!
cannot load such file -- mysql/mysql_api
/home/charul/coffee/config/application.rb:7:in `<top (required)>'
/home/charul/coffee/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
mysql安装在我的系统中。
[root@localhost coffee]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
这是我的database.yml文件。
development:
adapter: mysql
encoding: utf8
database: ajax
username: root
password: root123
host: 127.0.0.1
port: 3306
另外,bundle install命令工作正常。
[root@localhost coffee]# bundle install
Using rake (10.1.1)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.3)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.8)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.38)
Using actionpack (3.0.9)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.2.20)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using json (1.8.1)
Using mysql (2.9.1)
Using bundler (1.3.5)
Using rdoc (3.12.2)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
任何人都可以帮忙解决这个问题。谢谢
答案 0 :(得分:1)
你应该使用mysql2而不是mysql gem。只是做:
gem install mysql2
更改database.yml文件中的数据库适配器
development:
adapter: mysql
到
development:
adapter: mysql2
并更改你的Gemfile:
#gem 'mysql'
gem 'mysql2'
答案 1 :(得分:0)
env ARCHFLAGS="-arch x86_64" gem install mysql --version '2.8.1' -- --with-mysql- config=/usr/local/Cellar/mysql/5.5.15/bin/mysql_config