Laravel: Access denied for user homestead at localhost
<p>I just started a new Laravel project and I am having some database connectivity problem. First of all, I have only the User model which comes with the package. It has a migration as well. I updated my env file for the database path like this:</p>

<pre><code>DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel_project1
DB_USERNAME=root
DB_PASSWORD=''
</code></pre>

<p>The problem is, when I ran migrate command</p>

<pre><code>php artisan migrate
</code></pre>

<p>It created those migrations in my database. But now when I am simply trying to do User::all(); I am having some trouble with this error:</p>

<pre><code>SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from `users`)
</code></pre>

<p>I have even cleared my config cache with this command:</p>

<pre><code>php artisan config:clear
</code></pre>

<p>I don't understand what's wrong.</p>

<p>EDIT:</p>

<pre><code>    'mysql' =&gt; [
        'driver' =&gt; 'mysql',
        'host' =&gt; 'localhost',
        'port' =&gt; env('DB_PORT', '3306'),
        'database' =&gt; 'laravel_project1',
        'username' =&gt; 'root',
        'password' =&gt; '',
        'charset' =&gt; 'utf8',
        'collation' =&gt; 'utf8_unicode_ci',
        'prefix' =&gt; '',
        'strict' =&gt; true,
        'engine' =&gt; null,
    ],
</code></pre>

<p>This seems to solve the problem but I don't understand why env file is not working as it is the recommended way I believe.</p>