Laravel SQLSTATE [HY000] [2002] Connection refused

so I want to deploy my existing laravel object in my digitalocean vps. I use this site and successfully upload my site.

also my env file

APP_ENV=local
APP_KEY=my app key
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=my ip
DB_PORT=3306
DB_DATABASE=form
DB_USERNAME=root
DB_PASSWORD=my pass

but here is the problem

I used mysql and created and started php artisan migrateand got these errors, what is the problem

[Illuminate \ Database \ QueryException] SQLSTATE [HY000] [2002] Connection rejected (SQL: select * from information_schemes. Tables where table_schema = form and table_name = migrations)

and

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

+10
source share
4 answers

.env DB_HOST 127.0.0.1 localhost

+27

, .

  • , , phpmyadmin. , .
  • ; , .env, config/database.php
  • / , , , .

, . root (localhost, 127.0.0.1 :: 1).

, IP- .

digitalocean, , mysql.

+1

SELinux may be the cause.

Set this rule and try again:

sudo setsebool -P httpd_can_network_connect_db=1
+1
source

Put line:

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

after DB_PASSWORD =

This works for MAMP. Set your path to mysql.sock

0
source

Source: https://habr.com/ru/post/1664188/


All Articles