I'm trying to migrate the migrations I created, but i'm experiencing this error:
SQLSTATE[HY000] [1045] Access denied for user 'php'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = php and table_name = migrations)
I'm using homestead, and when I run other artisan commands on the vagrant vm everything works fine, I'm working with MacOS high sierra (which I read there was a problem with the new file format and vagrant, but it wasn't my case) and xampp.
I've read everything I've found relating to this issue (it's been two days of suffering). I've tried:
- Using 127.0.0.1 instead of localhost and viceversa in my .env file
- Typing the exact same configuration of my .env in my config/database.php (but i've read that this is a bad practice, since the configurations are in the env() method, so they take the .env values by default)
- I've changed the mysql port from 3306 to 33060
- I added this line Schema::defaultStringLength(191); to the boot() in appserviceprovider.php
- My user has the right credentials and all privileges, and I created the database before creating the migrations
- When I run netstat -ln | grep mysql on the xampp terminal it returns that the mysql socket port is this:
unix 2 [ ACC ] STREAM LISTENING 86094 /opt/lampp/var/mysql/mysql.sock
Which confuses me, since in my my.cnf file of /etc in xampp the port is set to be 3306, I already tried changing the .env port to 86094 but doesn't work.
When I run the same command (netstat -ln | grep mysql) in the vagrant vm it returns the port of the daemon socket:
unix 2 [ ACC ] STREAM LISTENING 20157 /var/run/mysqld/mysqld.sock
I don't know why the same command doesn't return the mysql socket port as well in the vagrant vm.
I'm using Laravel 5.6 with php 7.1.7
Some files as references:
.env
B_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=php
DB_USERNAME=php
DB_PASSWORD=php123
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' => '',
'strict' => true,
'engine' => null,
]
composer.json
"require": {
"php": ">=7.1.3",
"fideloper/proxy": "~4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "~1.0"
}
Homestead.yaml
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
sites:
- map: homestead.test
to: /home/vagrant/code/facturacion/public
databases:
- homestead
Thanks in advance, i'd really appreciate if someone can help me, this is driving me nuts