Laravel + Vagrant = Access denied for user 'root'@'localhost'

mysql, vagrant

Solution

According to Laravel docs:

To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret.

How did I test it (windows 7 x64 - git bash):

$ vagrant up $ vagrant ssh vagrant@homestead:~$ mysql -u root -p vagrant@homestead:~$ secret mysql>

Problem

I've seen that many users here on stackoverflow have a similar issue but following the answers I'm not able to make it work. When I run: ``` php artisan migrate ``` I get: ``` [PDOException] SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) ``` This is my app/config/app.php ``` 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'mio_sito', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), ``` The problem is that I don't actually have a password, if I login to vagrant with: ``` vagrant ssh ``` I can access mysql with: ``` mysql -u root ``` and no password is required. How can I fix this issue?

Original source