title: Laravel Migrate SQLSTATE[HY000] [2002] Connection refused
body: <p>I'm having errors when trying to migrate to localhost in laravel. Im in the process of learning how to use laravel but I can't connect to phpmyadmin database.</p>
  
  <p><strong>This is the error message in visual code terminal</strong> <br>
  When I change db host to localhost it gives me a error of PDOException::("SQLSTATE[HY000] [2002] No such file or directory")</p>
  
  <p><a href="https://i.stack.imgur.com/oo5Dv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oo5Dv.png" alt=""></a></p>
  
  <p><strong>This is my env. file</strong></p>
  
  <pre><code>APP_NAME=LSAPP 
  APP_ENV=local 
  APP_KEY=base64:Cv3S1V8GT1RKgpfilYmQM4aiM1HoXlwUMfh1oeL424I= 
  APP_DEBUG=true APP_URL=http://localhost
  
  LOG_CHANNEL=stack
  
  DB_CONNECTION=mysql 
  DB_HOST=127.0.0.1 
  DB_PORT=3306 
  DB_DATABASE=lsapp 
  DB_USERNAME=root 
  DB_PASSWORD=
  
  BROADCAST_DRIVER=log C
  ACHE_DRIVER=file 
  QUEUE_CONNECTION=sync 
  SESSION_DRIVER=file 
  SESSION_LIFETIME=120
  
  REDIS_HOST=127.0.0.1 
  REDIS_PASSWORD=null 
  REDIS_PORT=6379
  
  MAIL_DRIVER=smtp 
  MAIL_HOST=smtp.mailtrap.io 
  MAIL_PORT=2525 
  MAIL_USERNAME=null 
  MAIL_PASSWORD=null 
  MAIL_ENCRYPTION=null
  
  AWS_ACCESS_KEY_ID= 
  AWS_SECRET_ACCESS_KEY= 
  AWS_DEFAULT_REGION=us-east-1 
  AWS_BUCKET=
  
  PUSHER_APP_ID= 
  PUSHER_APP_KEY= 
  PUSHER_APP_SECRET= 
  PUSHER_APP_CLUSTER=mt1
  
  MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 
  MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
  </code></pre>
  
  <p>I dit change DBHOST to localhost and also tried other db usernames and db passwords but got no luck. My create posts code is as follow</p>
  
  <pre><code>Schema::create('posts', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;string('title');
              $table-&gt;mediumText('body');
              $table-&gt;timestamps();
          });
  </code></pre>
  
  <p>I also changed my AppServiceProvider.php to include Schema::defaultStringLength(191);
  I created the empty table also in phpmyadmin.</p>