PDOException SQLSTATE[HY000] [2002] No such file or directory

后端 未结 30 3211
南方客
南方客 2020-11-22 03:23

I believe that I\'ve successfully deployed my (very basic) site to fortrabbit, but as soon as I connect to SSH to run some commands (such as php artisan migrate

30条回答
  •  情书的邮戳
    2020-11-22 03:35

    As of Laravel 5 the database username and password goes in the .env file that exists in the project directory, e.g.

    DB_HOST=127.0.0.1
    DB_DATABASE=db1
    DB_USERNAME=user1
    DB_PASSWORD=pass1
    

    As you can see these environment variables are overriding the 'forge' strings here so changing them has no effect:

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
    

    More information is here https://mattstauffer.co/blog/laravel-5.0-environment-detection-and-environment-variables

提交回复
热议问题