0

I'm working on a Laravel 5.8 project using Homestead. The project works fine with database port is set to 3306 but I can't run artisan commands. When I change database port to 33060 database stops working but artisan commands work. with port 3306 whe I run any artisan command I get this message

enter image description here

And when I switch to 33060 error disappears and can run artisan commands but database stops working

APP_DEBUG=true
APP_URL=http://127.0.0.1
APP_ENV=local
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=forums
DB_USERNAME=homestead
DB_PASSWORD=secret

config/database.php

'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
        ]) : [],
    ],
PHP User
  • 2,350
  • 6
  • 46
  • 87

2 Answers2

1

Never used Homestead myself, but check out this related question:

Strange behaviour Laravel Homestead Database Connection

It seems that the error could be relative to whether or not you are running the commands in the VM or on your physical machine.

Ryan Ginnow
  • 83
  • 10
  • running artisan commands outside vagrant ssh won't work thanks for the hint. I have to run artisan commands inside vagrant ssh – PHP User May 18 '20 at 15:46
0

By default, a MySQL server listens to the port 3306, that's why it works. But if you wish another port, then you have to change your MySQL server setup.

How to change the default port of mysql from 3306 to 3360

Shizzen83
  • 3,325
  • 3
  • 12
  • 32