简体   繁体   中英

laravel 5 Access denied for user 'root'@' localhost' (using password: YES)

I am new to Laravel5. I tried to create migration table but I get this error

Error Log

This is the database.php

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'larashop'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'melody'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => false,
            'engine' => null,
        ],

and this is .env

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=larashop
DB_USERNAME=root
DB_PASSWORD=melody

Please help.

Your screenshot shows "localhost" and your code shows "127.0.0.1". MySQL treats "localhost" and "127.0.0.1" differently.

Make sure you have granted appropriate permissions for 'root'@'localhost' in your database.

http://dev.mysql.com/doc/refman/5.7/en/grant.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM