title: Laravel Artisan access denied for root@localhost on console only
body: <p>I have a problem with Laravel. My website has no problem accessing and performing operations on the database but when I try to run</p>
  
  <p><code>php artisan migrate</code></p>
  
  <p>On a terminal I get the error:</p>
  
  <blockquote>
    <p>[Illuminate\Database\QueryException]<br>
    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'
    (using pas     sword: NO) (SQL: select * from
    information_schema.tables where table_schema      = test and
    table_name = migrations)                                    </p>
    
    <p>[PDOException]<br>
    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost'
    (using pas     sword: NO)</p>
  </blockquote>
  
  <p>I have read every thread on the Internet about this error that I could find and none of them answered my question. It was always because people did not enter their database information correctly... However that is not my case since everything works fine in browser, I just cannot perform database related operations via the console like migrating or creating new database entries via <code>artisan tinker</code>.</p>
  
  <p>Here is what my config/database.php file:</p>
  
  <pre><code>'connections' =&gt; [
      'mysql' =&gt; [
          'driver' =&gt; 'mysql',
          'host' =&gt; env('DB_HOST', '127.0.0.1'),
          'port' =&gt; env('DB_PORT', '3306'),
          'database' =&gt; env('DB_DATABASE', 'test'),
          'username' =&gt; env('DB_USERNAME', 'root'),
          'password' =&gt; env('DB_PASSWORD', ''),
          'unix_socket' =&gt; env('DB_SOCKET', ''),
          'charset' =&gt; 'utf8mb4',
          'collation' =&gt; 'utf8mb4_unicode_ci',
          'prefix' =&gt; '',
          'strict' =&gt; true,
          'engine' =&gt; null,
      ],
  ]
  </code></pre>
  
  <p>And my .env config:</p>
  
  <pre><code>DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=test
  DB_USERNAME=root
  DB_PASSWORD=
  </code></pre>
  
  <p>I am stuck on figuring this problem out, so I appreciate your help a lot. I'm running XAMPP on my local machine and its on macOS 10.1.</p>