【问题标题】:Ruby on rails: mysql errorRuby on rails:mysql错误
【发布时间】:2012-02-05 14:01:18
【问题描述】:

我使用的是 windows xp 32 pro、bit、sp3。最新版本的railsinstallermysql2 gem

这周我一直在尝试解决这个错误。当我运行rake db:create 时,我看到了这个错误

this is what i see when i trace the error

我已经通过下载the zipped version of mysql Connector/C 6.0.2 for 32 bit 并从mysql-connector-c-noinstall-6.0.2-win32-vs2005\lib 复制libmysql.dll 解决了这个错误

C:\RailsInstaller\Ruby1.9.2\bin

现在当我运行rake db:create 时,我明白了

and this is what i see when i trace the error

我希望这些信息能帮助你,帮助我解决问题:)

@phoet

我的 gemfile

source 'http://rubygems.org'

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'mysql2'
gem 'cucumber'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'capybara'
gem 'rspec', '2.8'
gem 'rspec-rails', '2.8'
gem 'launchy'
gem 'spork'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

我的数据库配置

development:
  adapter: mysql
  database: selvista
  username: root
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: selvista_test
  username: root
  pool: 5
  timeout: 5000

production:
  adapter: mysql
  database: selvista_prod
  username: root
  pool: 5
  timeout: 5000

我的适配器应该是mysql2吗?

【问题讨论】:

  • 给出你认为可行的任何解决方案,我从不投反对票,因为谁回答我的问题是为了帮助
  • 请发布您正在使用的数据库配置和 gemfile。我假设您没有正确定义 mysql 依赖项。

标签: mysql ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1


【解决方案1】:

您可以尝试将 mysql2 放在 database.yml 中的适配器线上。

development:
  adapter: mysql2
  database: selvista
  username: root
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  database: selvista_test
  username: root
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  database: selvista_prod
  username: root
  pool: 5
  timeout: 5000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 2014-04-17
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多