SQLSTATE [HY000]连接被拒绝

时间:2016-06-25 06:54:09

标签: php mysql laravel pdo laravel-5

我试图让Laravel在远程服务器上工作。但当我运行“php artisan migrate”命令时,它会响应:

[PDOException]
SQLSTATE[HY000]  [2002] Connection refused

我谷歌寻求解决方案,到目前为止我尝试过:

  • 通过将.env重命名为.env.off;
  • 来禁用.env
  • 直接将数据库凭据设置为database.php;
  • 添加端口3306;
  • 数据库用户拥有所有权限;
  • 尝试将其作为“localhost”,127.0.0.1和远程IP运行;
  • 运行普通的PHP PDO连接,它连接;
  • 当我使用远程IP时,它说“Acces Denied for user'daniel ......”

.ENV

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:[secret]=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=daniel
DB_USERNAME=daniel
DB_PASSWORD=4K^2N(h}%V&S

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

database.php中

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'daniel'),
    'username' => env('DB_USERNAME', 'daniel'),
    'password' => env('DB_PASSWORD', '4K^2N(h}%V&S'),
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
],

0 个答案:

没有答案