【问题标题】:RoR: cannot connect to mysqlRoR:无法连接到 mysql
【发布时间】:2012-01-29 23:01:39
【问题描述】:

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

当我尝试做rake db:migraterake features 或与rake 相关的任何事情时,我看到this

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

我有 rails 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

宝石文件

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 我有很多文件夹和文件,我不知道'还不知道哪些文件重要,哪些文件不重要

【问题讨论】:

  • 您正在运行 Ruby 1.8.7。除非您有特殊原因,否则您应该运行最新版本。我看到你用了RailsInstaller。最新版本的 RailsInstaller 带有 Ruby 1.9.2。但我推荐 RubyInstaller 然后只是 gem install rails 和其他你想要的宝石。

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


【解决方案1】:

这适用于 XP 和 Windows 7、32 或 64 位。在第 2 步中,您需要下载适当的版本(32 位或 64 位)。我会先安装 ruby​​ gem pik 和 ruby​​ 1.9.3(或最新版本,如果更大),因为 ruby​​ 1.8.7 即将结束,但这取决于你。

  1. gem 安装 mysql2
  2. Download MySQL 6 connector
  3. 解压 msi 或 zip 文件。
  4. 将 libmysql.dll 移至路径上的目录。我的是 C:\ruby193\bin

从头开始的完整说明位于rubyat.com/blog

【讨论】:

    【解决方案2】:

    另外,我认为您还需要 MySQL2 gem。 https://github.com/brianmario/mysql2

    【讨论】:

    • sir mysql2 只适用于mysql 6.x 客户端,wamp 和xampp 没有mysql 6.x,都使用5.5,那么mysql2 怎么用呢?顺便说一句,我正在使用 xampp
    • 嗨,我正在运行 Ruby 1.9.2、Rails 3.2.1 和 MySQL 版本:5.5.13。和 mysql2 (0.3.11)。但是,我在 OSX / Ubuntu 11 上。也许你在不同的平台上运行。 S
    • 我在 xp 上,mysql2 说它需要 mysql 6 客户端,wamp 和 xampp 不提供 mysql 6 所以我不能使用 mysql2,除非我能以某种方式升级 mysql...我有xampp 已安装
    • 现在我有 Ruby 1.9.2-p290 和 rails Rails 3.1.1,当我运行 rake db:create 我看到:rake aborted! mysql客户端库版本不正确!这个 gem 是为 6.0.0 编译的,但是客户端库是 5.5.12
    猜你喜欢
    • 1970-01-01
    • 2014-04-09
    • 2011-01-02
    • 2011-03-14
    • 2021-02-05
    • 2017-04-09
    相关资源
    最近更新 更多