mysql - Ruby on Rails : mysql error

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

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

这周我一直在努力解决这个错误。当我运行 rake db:create 时,我看到此错误

enter image description here

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时我明白了

enter image description here

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吗?

最佳答案

您可以尝试将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

关于mysql - Ruby on Rails : mysql error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9149827/

相关文章:

java - 如何将java日期类型存储到mysql日期类型?

ruby-on-rails - 测试时按特定顺序加载 Rails fixture

ruby - "expect(9).to be > 6"如何是有效的表达?

ruby - 将我们的方法包含到整数类中

mysql - 两个表的 SQL 更新

php - 为数据库设置密码后无法访问phpMyAdmin

ruby-on-rails - Ruby 相当于 ActiveRecord Group by query

ruby-on-rails - 新项目使用哪个版本的 Rails?

ruby-on-rails - 要散列的 Rails 对象

mysql - 如何在将一个数据库与另一个数据库合并时解决主键冲突