RoR:无法连接到mysql

时间:2012-01-29 23:01:40

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

我是来自django的RoR的新手,RoR对我来说不像django那么容易,所以我希望你能帮助我

当我尝试rake db:migraterake features或有关rake的任何内容时,我会看到this

有三件事我不明白:为什么RoR没有连接到mysql?为什么我看到这个耙错误?为什么我看到ansicoon错误...我已经安装了3次(但这不是一个重要的错误,所以如果你不知道如何修复它那很好)我还安装了最新版本或今天耙

我有导轨3,windows xp 32位,sp3,我使用railsinstaller安装ror

的database.yml

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: &test
  adapter: mysql
  database: selvista_test
  username: root
  pool: 5
  timeout: 5000

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

cucumber:
  <<: *test

的Gemfile

source 'http://rubygems.org'

gem 'rails', '3.0.6'

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

gem 'mysql'
gem 'rake', '0.9.2.2'

#cucumber and some other gems

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

# 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

如果你需要看到任何其他文件告诉我,我习惯了django你有5个文件,你可以添加其他文件,如果你需要,这里有ruby on rails我有很多文件夹和文件,我不喜欢我不知道哪些文件很重要,哪些文件不重要

2 个答案:

答案 0 :(得分:2)

适用于XP和Windows 7,32或64位。在步骤2中,您需要下载适当的版本(32位或64位)。我首先安装ruby gem pik和ruby 1.9.3(或者更新的版本,如果更大),因为ruby 1.8.7即将达到使用寿命,但这取决于你。

  1. gem install mysql2
  2. Download MySQL 6 connector
  3. 解压缩msi或zip文件。
  4. 将libmysql.dll移动到路径上的目录。我的是C:\ ruby​​193 \ bin
  5. 从头开始的完整说明是rubyat.com/blog

答案 1 :(得分:1)

另外我认为你还需要MySQL2宝石。 https://github.com/brianmario/mysql2