vagrant環境にpgsql、laravelをインストールし、laravelが入っているフォルダのディレクトリ内でphp artisan migrateを実行すると以下のエラーが発生します。
.envとdatabase.php内のコードとエラー文、
sudo vi /var/lib/pgsql/14/data/pg_hba.confの中身を以下に表示します。
どの箇所が間違っているのかご指摘いただきたいです。
err
1 2 Illuminate\Database\QueryException 3 4 SQLSTATE[08006] [7] could not translate host name "127.0.0.1/32" to address: Name or service not known (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE') 5 6 at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703 7 699▕ // If an exception occurs when attempting to run a query, we'll format the error 8 700▕ // message to include the bindings with SQL, which will make this exception a 9 701▕ // lot more helpful to the developer instead of just the database's errors. 10 702▕ catch (Exception $e) { 11 ➜ 703▕ throw new QueryException( 12 704▕ $query, $this->prepareBindings($bindings), $e 13 705▕ ); 14 706▕ } 15 707▕ } 16 17 +36 vendor frames 18 37 artisan:37 19
env
1DB_CONNECTION=pgsql 2DB_HOST=127.0.0.1 3DB_PORT=5432 4DB_DATABASE=todo 5DB_USERNAME=postgres 6DB_PASSWORD=postgres
databasephp
1'pgsql' => [ 2 'driver' => 'pgsql', 3 'url' => env('DATABASE_URL'), 4 'host' => env('DB_HOST', '127.0.0.1'), 5 'port' => env('DB_PORT', '5432'), 6 'database' => env('DB_DATABASE', 'forge'), 7 'username' => env('DB_USERNAME', 'forge'), 8 'password' => env('DB_PASSWORD', ''), 9 'charset' => 'utf8', 10 'prefix' => '', 11 'prefix_indexes' => true, 12 'schema' => 'public', 13 'sslmode' => 'prefer', 14 ],
conf
1# TYPE DATABASE USER ADDRESS METHOD 2 3# "local" is for Unix domain socket connections only 4local all all peer 5# IPv4 local connections: 6#host all all 127.0.0.1 scram-sha-256 7host all all 127.0.0.1/32 trust 8# IPv6 local connections: 9#host all all ::1/128 scram-sha-256 10host all all ::1/128 trust 11# Allow replication connections from localhost, by a user with the 12# replication privilege. 13local replication all peer 14host replication all 127.0.0.1 scram-sha-256 15host replication all ::1/128 scram-sha-256 16 17
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。