Can't connect to mysql server

SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) (SQL: select * from `companies` where `id` = 1 limit 1)

File .Env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=secreet # <--- disamarin
DB_USERNAME=secrete # <--- disamarin
DB_PASSWORD=screte # <--- disamarin

File Controller

<?php
use App\models\Company;
use App\models\Project;
use App\models\Testimonial;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class CompanyController extends Controller
{
    public function index()
    {
      $companies = DB::table('companies')->where('id', 1)->first();
      $banners = Banner::all();
      $articles = Article::all();
      $projects = Project::all();
      $testimonials = Testimonial::all();
      return view('welcome', compact('projects', 'banners', 'articles', 'testimonials', 'companies'));
    }

Sehabis saya melakukan Deploy Laravel, tiba-tiba MySQL tidak mau terhubung. Apakah DB_HOST pada setiap hosting berbeda?

avatar Chata
@Chata

118 Kontribusi 19 Poin

Diperbarui 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban