【问题标题】:Ruby MySQL gem on Snow Leopard "couldn't create database" errorSnow Leopard 上的 Ruby MySQL gem“无法创建数据库”错误
【发布时间】:2010-10-14 00:18:13
【问题描述】:

环境:

Mac OS X 10.6.4

$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

$ rails -v
Rails 2.3.9

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.51, for apple-darwin10.3.0 (i386) using readline 5.1

$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/1.8/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
     - /Users/ethan/.gem/ruby/1.8
     - /Library/Ruby/Gems/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gemcutter.org"]
  - REMOTE SOURCES:
     - http://gemcutter.org

通过从 mysql.com 下载 mysql-5.1.51-osx10.6-x86.dmg 安装 MySQL。

像这样安装mysql gem:

$ sudo gem install mysql --no-rdoc --no-ri -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed

$ gem list -l | grep mysql
mysql (2.8.1)

MySQL 工作:

$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

问题:

$ rake db:create
(in /Users/.../project/employeedata)
Couldn't create database for {"encoding"=>"utf8", "adapter"=>"mysql", "username"=>"root", "database"=>"employeedata_development", "password"=>nil, "socket"=>"/tmp/mysql.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)

问题:

如何让 mysql gem 工作?

【问题讨论】:

    标签: mysql ruby-on-rails ruby


    【解决方案1】:

    我想知道这个讨论是否可以帮助你:rake db:create - collation issues

    看起来和你的问题一样。

    我想知道 mysql gem 是否真的为你编译好了。如果上面的链接没有帮助,你能告诉我当你这样做时会发生什么:

    ./script/console
    

    然后尝试访问您的一些模型?

    【讨论】:

    • 谢谢。我昨天确实尝试了这个基本序列,但我会更仔细地再试一次。到目前为止,我还无法创建数据库或运行 rake db:migrate,所以我无法连接到模型。
    • 您链接到的线程指向 Rails 官方网站上的this page,我按照那里的说明进行操作。但是,他们说要为 Mac OS 10.5 下载 MySQL DMG 文件,我认为这是一个错误。无论如何,10.6 DMG 在我的系统上运行。
    猜你喜欢
    • 2010-11-24
    • 2010-11-24
    • 2013-02-24
    • 1970-01-01
    • 2010-11-24
    • 2012-05-20
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多