DB 셋팅을 했는데도 왜 DB 연결이 되지 않는걸까요?

현재 DB는 mysql을 사용하고 app/config/database.php에 DB 셋팅을 다음과 같이 했습니다.

'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', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'test'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', '********'),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

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

],

그리고 컨트롤러에는 다음과 같이 작성하였습니다.

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use DB;

class Controller extends BaseController
{
    use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;

/**
* Show the example
*/

public function hello(){
    $test = DB::select('select * from test_table');
        return view('hello',['name'=>$test]);
    }
}

Route에는 다음과 같이 작성하였죠

Route::get('/test', 'Controller@hello');

이렇게 하고 접속해 보니 다음과 같은 에러가 나왔습니다.

PDOException in Connector.php line 55:
SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

  1. in Connector.php line 55

  2. at PDO->__construct('mysql:host=127.0.0.1;port=3306;dbname=homestead', 'homestead', 'secret', array('0', '2', '0', false, '0')) in Connector.php line 55

  3. at Connector->createConnection('mysql:host=127.0.0.1;port=3306;dbname=homestead', array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8unicodeci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 24

  4. at MySqlConnector->connect(array('driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8unicodeci', 'prefix' => '', 'strict' => false, 'engine' => null, 'name' => 'mysql')) in ConnectionFactory.php line 61

5 ...

저는 homestead를 설치하지도, 쓰지도 않는데 저 셋팅은 어디에서 나온것일까요?
혹시 제가 놓친 환경설정이 있을까요? ㅠㅠ

comments powered by Disqus