2011-06-01 105 views
0

我試圖建立一個MySQL數據庫,但我收到此錯誤信息:Rails的:耙分貝:創建MySQL錯誤

 
rake db:create 
(in /Users/yookd/Desktop/rails/blog) 
WARNING: Global access to Rake DSL methods is deprecated. Please Include 
    ... Rake::DSL into classes and modules which use the Rake DSL methods. 
WARNING: DSL method Blog::Application#task called at /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks' 
db/test.sqlite3 already exists 
rake aborted! 
uninitialized constant Mysql2 

Tasks: TOP => db:create 
(See full trace by running task with --trace) 

這個任何援助? (上http://guides.rubyonrails.org/getting_started.html以下方向)

編輯:::

如何使用MySQL作爲我的數據庫,而不是SQLite的?在gemfile中,它明確指出:gem 'sqlite' ...我是否需要用類似gem mysql的東西來替換那條線?

回答

2

這是一個已知問題。請參閱:Rails - rake db:create error

但請注意,Rake 0.9.1已被釋放,據稱可以修復事情。所以,第一次嘗試升級耙:

gem update rake 

並更新包:

bundle update rake 
0

您進行修改,是的,用你必須先安裝並在系統中配置的MySQL的MySQL。然後在你的Gemfile,刪除「寶石源碼」,取而代之的是:

gem 'mysql' 

然後,在你的config/database.yml中,將其設置類似於:

development: 
    adapter: mysql 
    database: name_of_database 
    pool: 5 
    timeout: 5000 
    host: localhost 
    password: mysql_password 

執行相同的測試和生產。