2010-10-14 47 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