2013-04-14 5 views
9

ここで少しぼんやりしています。データベースを作成しましたが、depot_productionデータベースを使用しても問題はありませんでした。私は熊手テストを実行するたびしかし、後半の、私は奇妙なことは、私は私のdatabase.ymlファイルは大丈夫だと思うですMysql2 ::エラー: 'test'というユーザーのアクセスが拒否されました@ 'localhost' from database 'depot_test'

# Running tests: 

EEEEEEEE 

Finished tests in 0.031499s, 253.9763 tests/s, 0.0000 assertions/s. 

1) Error: 
test_should_create_product(ProductsControllerTest): 
Mysql2::Error: Access denied for user 'test'@'localhost' to database 'depot_test' 

ようなエラーの束を取得します。そして毎回私はdb:migrateを実行します。私は空の行を返します。また、ユーザーテストも追加しましたが、開発データベースに追加しただけと思います。私はみかんのおかげで、何かアドバイスをいただければ幸いです

development: 
adapter: mysql2 
encoding: utf8 
reconnect: false 
database: depot_development 
pool: 5 
username: root 
password: admin 
socket: /tmp/mysql.sock 

# 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: depot_test 
pool: 5 
username: test 
password: testy 
socket: /tmp/mysql.sock 

production: 
adapter: mysql2 
encoding: utf8 
reconnect: false 
database: depot_production 
pool: 5 
username: prod 
password: mypassword 
socket: /tmp/mysql.sock 

...私のテストと生産およびデータベースが存在しないと思います。

ここで私にこだわってくれてありがとう。私は近くにいるように感じますが、何か奇妙です。ここに私がしたことがあります。 ルートまたは何あなたのrootユーザが端末から呼び出されるよう

mysql> use depot_test; 
ERROR 1049 (42000): Unknown database 'depot_test' 
mysql> show databases; 
+--------------------+ 
| Database   | 
+--------------------+ 
| information_schema | 
| depot_development | 
| development  | 
| mysql    | 
| performance_schema | 
| test    | 
+--------------------+ 
6 rows in set (0.01 sec) 

mysql> use depot_test 
ERROR 1049 (42000): Unknown database 'depot_test' 
mysql> use test 
Database changed 
mysql> GRANT SELECT, INSERT, DELETE ON `test` TO [email protected]'localhost' IDENTIFIED BY 'testy'; 
ERROR 1146 (42S02): Table 'test.test' doesn't exist 
mysql> GRANT SELECT, INSERT, DELETE ON `depot_test` TO [email protected]'localhost' IDENTIFIED BY  'testy'; 
ERROR 1146 (42S02): Table 'test.depot_test' doesn't exist 
+0

"test"というユーザーに "depot_test"を変更する権限を与える必要があります – 1337holiday

答えて

19

だから、最初のログイン。あなたは、MySQLにログインしたら

mysql -u root -p 

CREATE DATABASE depot_test 

CREATE USER 'test'@'localhost' IDENTIFIED BY 'mypass123'; 

USE depot_test 

は、ユーザーtestに権限を付与(パスワードを変更することを忘れないでください)

GRANT ALL privileges on depot_test.* to [email protected] identified by 'mypass123'; 

FLUSH PRIVILEGES; 

あなたのdatabase.ymlの中であなたのパスに「mypass123」に変更する必要があります

+0

ありがとうございます!私は次のように試してみた。 ERROR 1046(3D000):データベースが選択されていません – DynastySS

+0

ああ、 'depot_test'データベースを選択する必要があります。 – 1337holiday

+0

の編集をご覧ください。元の投稿を編集して追加しました。ありがとう! – DynastySS

関連する問題