我開始一個新的Rails應用程序3,當我運行rake db:create
它要求我的MySQL的root密碼,然後出現了錯誤說:耙分貝:創建只有創造發展DATABSE
Mysql2::Error: Access denied for user 'arcsite_mysql'@'localhost' to database 'arcsite_mysql_test': CREATE DATABASE `arcsite_mysql_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
如果我登錄到MySQL上在命令行和運行show databases;
我看到這一點:
arcsite_mysql_development
如果我跑SHOW GRANTS FOR [email protected]
我看到這一點:
GRANT ALL PRIVILEGES ON `arcsite_mysql_development`.* TO 'arcsite_mysql'@'localhost' WITH GRANT OPTION
我的database.yml:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: arcsite_mysql_development
pool: 5
username: arcsite_mysql
password: password
host: localhost
# 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:
adapter: mysql2
encoding: utf8
reconnect: false
database: arcsite_mysql_test
pool: 5
username: arcsite_mysql
password: password
host: localhost
所以,出於某種原因,正在創建僅開發數據庫。
版本:
的Rails 3.2.13
MySQL的:服務器版本:5.6.10源分佈
mysql2:mysql2-0.3.11
編輯
如果我手動授予arcsite_mysql
用戶的所有權限,我可以創建這些表。但是預計Rails會爲開發創建用戶和表,但不是爲了測試環境?當我第一次運行rake db:create
命令時,arcsite_mysql
用戶由rails創建。
EDIT 2
提到關於 「衆所周知」 的過程,涉及到mysql用戶創建的東西。
用戶'arcsite_mysql'是否存在於mysql中?如果此用戶存在並且具有適當的權限,我認爲它不應該要求您提供root密碼。如果不是這樣的話: 'GRANT ALL *。* TO'arcsite_mysql'@'localhost'IDENTIFIED BY'password';' – 2013-04-23 17:51:32
我以爲Rails負責在mysql中創建用戶嗎?用戶在運行'rake db:create'命令之前並不存在。 – 2013-04-23 17:54:54
稍微更新了這個問題。用戶創建行爲似乎有點時髦 – 2013-04-23 18:04:19