0

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!

Community
  • 1
  • 1
henriale
  • 1,012
  • 9
  • 21
  • Do you run in browser domain mapped into Vagrant server? I've been using Vagrant for a while and had no problems with DB and ports. Standard 3306 is working fine in Laravel config when you connect to database located also in Vagrant – Marcin Nabiałek Dec 20 '15 at 16:34
  • @MarcinNabiałek you remembered me that I also have a vagrant vm that is working. I'll try to copy it and give some feedback. thanks! – henriale Dec 20 '15 at 21:28
  • I have the exact same issue. – kratos Jul 05 '16 at 20:08

0 Answers0