title: Laravel 5 - Unknown Database
body: <p>I'm trying to make a login form in laravel 5. </p>
  
  <p>Everytime I try to log in I get the error</p>
  
  <blockquote>
    <p>PDOException in Connector.php line 55: SQLSTATE[42000] [1049] Unknown
    database 'php2project'</p>
  </blockquote>
  
  <p>However the database exists.
  <a href="https://i.stack.imgur.com/bm42J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bm42J.png" alt="enter image description here"></a></p>
  
  <p>I could use "php artisan migrate" without any problem, so I have no idea why I'm having this issue right now.</p>
  
  <p>here's how my .env file looks</p>
  
  <pre><code>APP_ENV=local
  APP_DEBUG=true
  APP_KEY=_STACK_
  
  DB_HOST=127.0.0.1
  DB_DATABASE=php2project
  DB_USERNAME=root
  DB_PASSWORD=_STACK_
  
  CACHE_DRIVER=file
  SESSION_DRIVER=file
  QUEUE_DRIVER=sync
  
  MAIL_DRIVER=smtp
  MAIL_HOST=mailtrap.io
  MAIL_PORT=2525
  MAIL_USERNAME=null
  MAIL_PASSWORD=null
  MAIL_ENCRYPTION=null
  </code></pre>
  
  <p>EDIT: Here is my config/database information</p>
  
  <pre><code>'default' =&gt; env('DB_CONNECTION', 'mysql'),
  
  /*
  |--------------------------------------------------------------------------
  | Database Connections
  |--------------------------------------------------------------------------
  |
  | Here are each of the database connections setup for your application.
  | Of course, examples of configuring each database platform that is
  | supported by Laravel is shown below to make development simple.
  |
  |
  | All database work in Laravel is done through the PHP PDO facilities
  | so make sure you have the driver for your particular database of
  | choice installed on your machine before you begin development.
  |
  */
  
  'connections' =&gt; [
  
      'sqlite' =&gt; [
          'driver'   =&gt; 'sqlite',
          'database' =&gt; database_path('database.sqlite'),
          'prefix'   =&gt; '',
      ],
  
      'mysql' =&gt; [
          'driver'    =&gt; 'mysql',
          'host'      =&gt; env('DB_HOST', 'localhost'),
          'database'  =&gt; env('DB_DATABASE', 'forge'),
          'username'  =&gt; env('DB_USERNAME', 'forge'),
          'password'  =&gt; env('DB_PASSWORD', ''),
          'charset'   =&gt; 'utf8',
          'collation' =&gt; 'utf8_unicode_ci',
          'prefix'    =&gt; '',
          'strict'    =&gt; false,
      ],
  
      'pgsql' =&gt; [
          'driver'   =&gt; 'pgsql',
          'host'     =&gt; env('DB_HOST', 'localhost'),
          'database' =&gt; env('DB_DATABASE', 'forge'),
          'username' =&gt; env('DB_USERNAME', 'forge'),
          'password' =&gt; env('DB_PASSWORD', ''),
          'charset'  =&gt; 'utf8',
          'prefix'   =&gt; '',
          'schema'   =&gt; 'public',
      ],
  
      'sqlsrv' =&gt; [
          'driver'   =&gt; 'sqlsrv',
          'host'     =&gt; env('DB_HOST', 'localhost'),
          'database' =&gt; env('DB_DATABASE', 'forge'),
          'username' =&gt; env('DB_USERNAME', 'forge'),
          'password' =&gt; env('DB_PASSWORD', ''),
          'charset'  =&gt; 'utf8',
          'prefix'   =&gt; '',
      ],
  
  ],
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>&lt;?php
  namespace App\Http\Controllers;
  use View;
  use Auth;
  use Illuminate\Support\Facades\Validator;
  use Illuminate\Support\Facades\Input;
  use Illuminate\Support\Facades\Redirect;
  
  class LogInController extends Controller 
  {
      public function showLogin()
      {
          return View::make('login.login');
      }
  
      public function doLogin()
      {
          // validate
          $rules = array(
              'email'    =&gt; 'required|email',
              'password' =&gt; 'required|alphaNum|min:3'
          );
          // run the validation rules on the inputs from the form
          $validator = Validator::make(Input::all(), $rules);
  
          // if the validator fails, redirect back to the form
          if ($validator-&gt;fails()) {
              return Redirect::to('login')
                  -&gt;withErrors($validator)
                  -&gt;withInput(Input::except('password'));
          } else {
              // create our user data for the authentication
              $userdata = array(
                  'email'     =&gt; Input::get('email'),
                  'password'  =&gt; Input::get('password')
              );
              // attempt to do the login
              if (Auth::attempt($userdata)) {
  
                  // validation successful!
                  // redirect them to the secure section or whatever
                  // return Redirect::to('secure');
                  // for now we'll just echo success (even though echoing in a controller is bad)
                  echo 'SUCCESS!';
  
              } else {        
  
                  // validation not successful
                  return Redirect::to('login');
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>view</strong></p>
  
  <pre><code>@extends('layouts.master')
  @section('title', 'Login')
  @section('content')
  
  {!! Form::open(array('url' =&gt; 'login')) !!}
      &lt;h1&gt;Login&lt;/h1&gt;
      &lt;p&gt;
          {!! $errors-&gt;first('email') !!}
          {!! $errors-&gt;first('password') !!}
      &lt;/p&gt;
  
      &lt;p&gt;
          {!! Form::label('email', 'Email Address') !!}
          {!! Form::text('email', Input::old('email'), array('placeholder' =&gt; 'john@snow.com')) !!}
      &lt;/p&gt;
  
      &lt;p&gt;
          {!! Form::label('password', 'Password') !!}
          {!! Form::password('password') !!}
      &lt;/p&gt;
  
      &lt;p&gt;{!! Form::submit('Submit!') !!}&lt;/p&gt;
  {!! Form::close() !!}
  </code></pre>