1
votes

Using Mac OS X, MAMP 5.5 and Laravel 5.8.35

When I use 'php artisan migrate' I get the following error message:

Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = auth and table_name = migrations and table_type = 'BASE TABLE')

at /Applications/MAMP/htdocs/auth/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

file .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth
DB_USERNAME=etn
DB_PASSWORD=pass

the same thing with

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=auth
DB_USERNAME=etn
DB_PASSWORD=pass

migrarion file

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

second migration file:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePasswordResetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('password_resets');
    }
}
2
Have you tried running php artisan config:clearpetersowah
yes, both with php artisan config:cache and php artisan config:clearDaniele Mastroberti
share your query in migration fileSalunkeAkash
are you sure your database already running? Connection refused mean your app failed to connect to the databaseazisuazusa
@SalunkeAkash addedDaniele Mastroberti

2 Answers

2
votes

Try this changes

  DB_PORT=33060

Or

 DB_PORT=8889

Stop and restart server after changes.

0
votes

One of its cause, that the server XAMPP has not been started try to check the server that you started it accurately or no at your local host.