douhang8991
2019-05-15 18:51
浏览 74
已采纳

QueryException SQLSTATE [HY000] [2002]无法连接到MySQL服务器

QueryException SQLSTATE[HY000] [2002] Can't connect to MySQL server on '127.0.0.1' (110)

When I put this project into another server it works fine . Is there any problem with server configuration ?

in database.php

'default' => env('DB_CONNECTION', 'mysql'),



'connections' => [

    'sqlite' => [
        'driver' => 'sqlite',
        'database' => env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' => '',
    ],

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => 'projapati',
        'username' => 'projapati',
        'password' => 'AHt!j![(dl',
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

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

],

How can I solve this problem?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongliyu3278 2019-05-15 19:03
    已采纳

    Change this

    'host' => env('DB_HOST', '127.0.0.1'),

    to this

    'host' => env('DB_HOST', 'localhost'),

    点赞 打赏 评论

相关推荐 更多相似问题