curl -s "https://laravel.build/example-app" | bash
我使用上面的命令安装 laravel8 和sail up
这一切都很好。
但是,我也想测试mysql。
mysql_test:
image: "mysql:8.0"
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
networks:
- sail
我在上面添加到 docker-composer.yml 并运行sail up
DB_CONNECTION=mysql
DB_HOST=mysql_test
DB_PORT=3306
DB_DATABASE=laravel8_test
DB_USERNAME=sail
DB_PASSWORD=password
.env.testing
但是当我跑的时候sail test
,我得到了一个错误
SQLSTATE[HY000] [1044] Access denied for user 'sail'@'%' to database 'laravel8_test' (SQL: select * from `users`)
我跑的测试是
public function test_example()
{
dd(User::all());
$response = $this->get('/');
$response->assertStatus(200);
}
我还应该做什么?