新しいRails 3アプリを開始しています。実行rake db:create
すると、root mysqlパスワードを要求され、次のエラーが表示されます。
Mysql2::エラー: ユーザー 'arcsite_mysql'@'localhost' のデータベース 'arcsite_mysql_test' へのアクセスが拒否されました: CREATE DATABASE
arcsite_mysql_test
DEFAULT CHARACTER SETutf8
COLLATEutf8_unicode_ci
コマンド ラインで mysql にログインして実行すると、次のようshow databases;
に表示されます。
arcsite_mysql_development
実行すると、次のようSHOW GRANTS FOR arcsite_mysql@localhost
に表示されます。
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
そのため、何らかの理由で、開発データベースのみが作成されています。
バージョン:
レール 3.2.13
MySQL: サーバー バージョン: 5.6.10 ソース配布
mysql2: mysql2-0.3.11
編集
ユーザーにすべての権限を手動で付与arcsite_mysql
すると、テーブルを作成できます。しかし、Rails はテスト環境ではなく開発用にユーザーとテーブルを作成すると予想されるのでしょうか? コマンドを最初に実行したarcsite_mysql
ときに、レールによってユーザーが作成されますrake db:create
。
編集2
mysql ユーザーの作成を含む「よく知られている」プロセスについて言及しています。