title: how to change database name in laravel? changing config>database.php doesn't work
body: <p>I created a database "mydatabase" and I changed config>database.php to:</p>
  
  <pre><code>'mysql' =&gt; array(
          'driver'    =&gt; 'mysql',
          'host'      =&gt; 'mysite.local',
          'database'  =&gt; 'mydatabase',
          'username'  =&gt; 'myusername',
          'password'  =&gt; 'mypassword',
          'charset'   =&gt; 'utf8',
          'collation' =&gt; 'utf8_unicode_ci',
          'prefix'    =&gt; '',
      ),
  </code></pre>
  
  <p>now inside route.php i have:</p>
  
  <pre><code>    Route::get('/', function()
  {
      $data=DB::table('user')-&gt;get();
      return $data;
  });
  </code></pre>
  
  <p>laravel sends an Exception which shows that it tries to access:</p>
  
  <pre><code>homestead.user
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>mydatabase.user
  </code></pre>
  
  <p>now if i change route.php to:</p>
  
  <pre><code>    Route::get('/', function()
  {
      $data=DB::table('mydatabase.user')-&gt;get();
      return $data;
  });
  </code></pre>
  
  <p><strong>it will work!</strong></p>
  
  <p>Also according to <a href="https://stackoverflow.com/questions/25317370/changing-database-name-in-laravel-homestead">this question</a> I changed config>local>database.php to:</p>
  
  <pre><code>'mysql' =&gt; array(
          'driver'    =&gt; 'mysql',
          'host'      =&gt; 'mysite.local',
          'database'  =&gt; 'mydatabase',
          'username'  =&gt; 'myusername',
          'password'  =&gt; 'mypassword',
          'charset'   =&gt; 'utf8',
          'collation' =&gt; 'utf8_unicode_ci',
          'prefix'    =&gt; '',
      ),
  </code></pre>
  
  <p>But this time, even </p>
  
  <pre><code>$data=DB::table('mydatabase.user')-&gt;get();
  </code></pre>
  
  <p>doesn't work either! This time it thrown another exception :</p>
  
  <pre><code>PDOException (2002) 
  SQLSTATE[HY000] [2002] Connection refused
  </code></pre>
  
  <p><strong>My question is why laravel tries to use "homestead" database instead of "mydatabase"? should I change something else?</strong></p>
  
  <p><strong>EDIT:</strong>
  I changed the config/local/database.php to </p>
  
  <pre><code>'mysql' =&gt; array(
          'driver'    =&gt; 'mysql',
          'host'      =&gt; 'localhost',
          'database'  =&gt; 'mydatabase',
          'username'  =&gt; 'myusername',
          'password'  =&gt; 'mypassword',
          'charset'   =&gt; 'utf8',
          'collation' =&gt; 'utf8_unicode_ci',
          'prefix'    =&gt; '',
      ),
  </code></pre>
  
  <p>and everything works fine! (I changed mysite.local to localhost)
  <strong>I've not define local host in my /etc/hosts so why laravel looks for that host?</strong></p>