title: Access denied for user 'root'@'localhost' with postman API only
body: <p>I'm using postman to try and make an API post request:</p>
  
  <blockquote>
    <p><a href="http://127.0.0.1:8000/api/auth/register?name=corbin&amp;email=corbin@example.com&amp;password=password" rel="nofollow noreferrer">http://127.0.0.1:8000/api/auth/register?name=corbin&amp;email=corbin@example.com&amp;password=password</a></p>
  </blockquote>
  
  <p>There must be a database connecting because I can migrate my db just fine. Using <code>php artisan tinker</code> I can also add a new user just fine:</p>
  
  <pre><code>&gt;&gt;&gt; $user = new User();
  =&gt; App\User {#3060}
  &gt;&gt;&gt; $user-&gt;name = "kyle";
  =&gt; "kyle"
  &gt;&gt;&gt; $user-&gt;email = "kyle@example.com"
  =&gt; "kyle@example.com"
  &gt;&gt;&gt; $user-&gt;email = "kyle@example.com";
  =&gt; "kyle@example.com"
  &gt;&gt;&gt; $user-&gt;password = bcrypt('password');
  =&gt; "$2y$10$VQ8i0wlUKOfMzz6s/AXNBekcAdDAah9EvCvLeOASu3t06x.eVMCFq"
  &gt;&gt;&gt; $user-&gt;save();
  =&gt; true
  &gt;&gt;&gt; User::all();
  =&gt; Illuminate\Database\Eloquent\Collection {#3080
       all: [
         App\User {#3081
           id: 1,
           name: "kyle",
           email: "kyle@example.com",
           email_verified_at: null,
           created_at: "2020-04-29 06:15:03",
           updated_at: "2020-04-29 06:15:03",
         },
       ],
     }
  </code></pre>
  
  <p>However when I try and create a record in postman I get this:</p>
  
  <blockquote>
    <p>Illuminate\Database\QueryException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: insert into <code>users</code> (<code>name</code>, <code>email</code>, <code>password</code>, <code>updated_at</code>, <code>created_at</code>) values (kyle, kyle@example.com, $2y$10$QfVSBr67zOJldKrxqjVVsO9pZ5QV9qOkvoCH./FPRZfSRVo1A4GqC, 2020-04-28 08:53:51, 2020-04-28 08:53:51)) in file /Applications/MAMP/htdocs/laravel-vue-spa/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 671</p>
  </blockquote>
  
  <p>Here's my AuthController:</p>
  
  <pre><code>public function register(Request $request)
      {
  
  
          /*$request-&gt;validate([
              'name' =&gt; 'required|string|max:255',
              'email' =&gt; 'required|string|email|max:255|',
              'password' =&gt; 'required|string|min:6|confirmed'
          ]);*/
  
          $user = new User();
          $user-&gt;name = $request-&gt;name;
          $user-&gt;email = $request-&gt;email;
          $user-&gt;password = bcrypt($request-&gt;password);
  
          $user-&gt;save();
  
          /*if($user-&gt;save()){
              return response()-&gt;json([
                  'message' =&gt; 'User was successfully created.',
                  'status_code' =&gt; 201
              ], 201);
          } else {
              return response()-&gt;json([
                  'message' =&gt; 'An error occured. Please try again.',
                  'status_code' =&gt; 500
              ], 500);
          } */
      }
  </code></pre>
  
  <p><strong>.env</strong></p>
  
  <pre><code>DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=laravel_spa
  DB_USERNAME=root
  DB_PASSWORD=password
  </code></pre>
  
  <p>I also tried switching <code>DB_HOST=localhost</code>. In Sequel Pro my privileges are set to super. I've also tried doing a <code>GET</code> request for <code>User::all();</code> same ordeal.</p>
  
  <h1>Edit 1</h1>
  
  <p><strong>config/database.php</strong></p>
  
  <pre><code>'mysql' =&gt; [
              'driver' =&gt; 'mysql',
              'url' =&gt; env('DATABASE_URL'),
              'host' =&gt; env('DB_HOST', '127.0.0.1'),
              'port' =&gt; env('DB_PORT', '3306'),
              'database' =&gt; env('DB_DATABASE', 'forge'),
              'username' =&gt; env('DB_USERNAME', 'forge'),
              'password' =&gt; env('DB_PASSWORD', ''),
              '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>
  
  <p>I have also ran <code>php artisan config:clear</code> and <code>php artisan optimize:clear</code></p>