I Can’t show my database tables through migration command on powershell terminal (Windows 10)

I tried to run: php artisan migrate

Also to connect to MySQL using terminal on Windows.

I Got this error:

  SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it (SQL: select * from information_schema.tables where table_schema = firstproject and table_name = migrations and table_type = 'BASE TABLE')

  at C:UsersekindDesktopLaravelTestFirstProjectvendorlaravelframeworksrcIlluminateDatabaseConnection.php:692
    688▕         // If an exception occurs when attempting to run a query, we'll format the error
    689▕         // message to include the bindings with SQL, which will make this exception a
    690▕         // lot more helpful to the developer instead of just the database's errors.
    691▕         catch (Exception $e) {
  ➜ 692▕             throw new QueryException(
    693▕                 $query, $this->prepareBindings($bindings), $e
    694▕             );
    695▕         }
    696▕     }

  1   C:UsersekindDesktopLaravelTestFirstProjectvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70
      PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it")

  2   C:UsersekindDesktopLaravelTestFirstProjectvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70

.env file:

I tried to change my DB_HOST to “localhost” but it didn’t work.

When I want to show databases it shows those;

mysql> show databases;
| Database           |
| firstproject       |
| firstprojectdb     |
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| world              |

But even if I create tables like these it didn’t see
public function up()

    Schema::create('posts', function (Blueprint $table) {
        $table->increments('id'); // İdentity(1,1) İd int
        $table->string('title');  // title (Create a new string column on the table.)
        $table->mediumText('body'); // body  (Create a new medium text column on the table.)

As you see;
mysql> show tables;
Empty set (0.00 sec)

I even delete the extension of “extension=pdo_mysql” but it didn’t work to me.



Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try to make sure that your server is running, if you are working on the localhost check your Xampp that the server and mysql both are running. see image here make sure these are not stopped like this First run: php artisan migrate and then if you get the error check your .env, that you have provided the correct details or not.

Note: localhost by default have no password, make sure that you have the same password and database name.

Furthermore, if the above doesn’t work for you then try the below commands:

php artisan config:cache

and then:
php artisan migrate

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x