I have faced the same problem as reported here, but instead of the given solution, I could solve by just changing the port from 3306
to 33060
and everything worked fine in command line as I ran php artisan:migrate
.
however, if I change again from 33060
to 3306
I can access my application through the browser but not through the command line again.
I thought that it might be the vagrant, so I created an environment variable for
each of the agents and placed them in my database.php
file, as below:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost') .':'. (php_sapi_name() === 'cli' ? env('DB_PORT_CLI') : env('DB_PORT')),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Now, both browser and CLI are working, but still I think it's not the best solution.
Has anyone faced the same problem? how could I solve it neatly?
Thanks in advance!