2010-10-14 46 views
0

环境:

的Mac OS X 10.6.4雪豹红宝石MySQL的宝石 “无法创建数据库” 错误

$ 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的宝石是这样的:

$ 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的宝石上班?

回答

1

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

似乎是同样的问题你。

我想知道如果MySQL的宝石实际编译为你好。如果上面的链接没有帮助,你能告诉我,当你这样做会发生什么:

./script/console 

,然后试图访问你的一些型号的?

+0

谢谢。我昨天尝试了这个基本顺序,但我会再仔细一点再试一次。到目前为止,我还没有能够创建数据库或运行rake db:migrate,因此我无法连接到模型。 – Ethan 2010-10-14 17:52:31

+0

您在官方Rails网站上链接到[本页](http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard)的线索,我按照其中的说明操作。但是,他们说要为Mac OS 10.5下载MySQL DMG文件,我认为这是一个错误。无论如何,10.6 DMG在我的系统上工作。 – Ethan 2010-11-11 00:59:17