LoginSignup
2
1

More than 1 year has passed since last update.

sailでテスト用データベースに接続できないときの対処法

Posted at

Laravelのtestで画面回りのテストをするを参考に、
テスト用の.env.testingを作成し、
mysqlでhoge_testingデータベースを作成し、
マイグレーションをしようとしたところ、
SQLSTATE[HY000] [1044] Access denied for user 'sail'@'%' to database 'hoge_testing' とのエラーが出た。
sailにテスト用データベースの権限を与えれば良い

mysqlのコンテナに接続

docker container exec -it [ハッシュ値] bash
mysql -u root -p

sailにテスト用データベースの全てのテーブルに対し全権限を与える。

mysql> grant all on hoge_testing.* sail;
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1