Laravel工匠迁移连接错误

时间:2017-10-22 12:38:43

标签: laravel artisan

我正在尝试使用迁移和流浪盒创建用户表。当我使用artisan migrate时,我收到此错误:

SQLSTATE[08006] [7] could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "127.0.0.1" and accepting                                                         
        TCP/IP connections on port 5432? (SQL: select * from information_schema.tables where table_schema = public and tab
  le_name = migrations)

  [PDOException]
  SQLSTATE[08006] [7] could not connect to server: Connection refused (0x0000274D/10061)
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?

我需要更改哪个文件来设置我的连接以及我需要使用哪些详细信息?

这是我的数据库配置:

    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'homestead'),
        'username' => env('DB_USERNAME', 'secret'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],

我的.env文件:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=homestead
DB_USERNAME=homestead 
DB_PASSWORD=secret

我的php.ini中的dll已取消注释,并指向正确的扩展目录:

;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_shmop.dll

当我尝试使用vagrant时,我得到错误:

vagrant@homestead:~$ php artisan migrate
Could not open input file: artisan
vagrant@homestead:~$

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

当我将54320添加为A PORT时遇到了相同的问题 只需将0添加到端口即可。

答案 1 :(得分:-2)

这只是意味着您的MySQL服务器不能在不同的IP地址或端口上运行或运行。