title: SQLSTATE[HY000] [1045] Access denied for user 'rentacar'@'localhost' (using password: YES)
body: <p>I am new to Laravel. I just created a project, embedded a html Admin template Frest (also tried Admin LTE). When I tried to create tables using php artisan migrate i got this error</p>
  
  <pre><code>     Illuminate\Database\QueryException 
  
    SQLSTATE[HY000] [1045] Access denied for user 'rentacar'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = rentacar and table_name = migrations and table_type = 'BASE TABLE')
  
    at C:\wamp64\www\CRS\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
      667|         // If an exception occurs when attempting to run a query, we'll format the error
      668|         // message to include the bindings with SQL, which will make this exception a   
      669|         // lot more helpful to the developer instead of just the database's errors.     
      670|         catch (Exception $e) {
    &gt; 671|             throw new QueryException(
      672|                 $query, $this-&gt;prepareBindings($bindings), $e
      673|             );
      674|         }
      675| 
  
    1   C:\wamp64\www\CRS\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:31
        Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'rentacar'@'localhost' (using password: YES)")
  
    2   C:\wamp64\www\CRS\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:27
        PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'rentacar'@'localhost' (using password: YES)")
  </code></pre>
  
  <p>I tried to change the database name as "laravel", created a database named "laravel", and user as root password null. I setup both files .env and database.php files with credentials. But when I use a database with no password I am getting error saying "unknown database".</p>
  
  <p>How can I fix this issue?</p>
  
  <p>I have tried these steps</p>
  
  <pre><code>php artisan config:clear
  php artisan cache:clear
  php artisan view:clear
  php artisan config:cache
  </code></pre>
  
  <p>then I tried to run this command </p>
  
  <pre><code>php artisan serve
  </code></pre>
  
  <p>and ctrl+c and then tried again <code>php artisan migrate</code> but got same error
  I also tried deleting the bootstrap/config.php file but the error is still same, even I tried to change db host to 127.0.0.1 from localhost but in vain.</p>
  
  <p>Here is my .env </p>
  
  <pre><code>APP_NAME=Laravel
  APP_ENV=local
  APP_KEY=base64:BrzpwPAf/MVFBphATZTk4dwNTPbmnOO08jJMY35hIsI=
  APP_DEBUG=true
  APP_URL=http://localhost
  
  LOG_CHANNEL=stack
  
      DB_CONNECTION=mysql
      DB_HOST=localhost
      DB_PORT=3306
      DB_DATABASE=rentacar
      DB_USERNAME=rentacar
      DB_PASSWORD=carchahiyesir
  </code></pre>
  
  <p>here is my database.php</p>
  
  <pre><code>    'mysql' =&gt; [
      'driver' =&gt; 'mysql',
      'url' =&gt; env('DATABASE_URL'),
      'host' =&gt; env('DB_HOST', 'localhost'),
      'port' =&gt; env('DB_PORT', '3306'),
      'database' =&gt; env('DB_DATABASE', 'rentacar'),
      'username' =&gt; env('DB_USERNAME', 'rentacar'),
      'password' =&gt; env('DB_PASSWORD', 'carchahiyesir'),
      'unix_socket' =&gt; env('DB_SOCKET', ''),
      'charset' =&gt; 'utf8mb4',
      'collation' =&gt; 'utf8mb4_unicode_ci',
      'prefix' =&gt; '',
      'prefix_indexes' =&gt; true,
      'strict' =&gt; true,
      'engine' =&gt; null,
      'options' =&gt; extension_loaded('pdo_mysql') ? array_filter([
          PDO::MYSQL_ATTR_SSL_CA =&gt; env('MYSQL_ATTR_SSL_CA'),
      ]) : [],
      ],
  </code></pre>