Laravel 解决[1045] Access denied for user 'homestead'@'localhost'
看到这种提示首先去检查自己的配置信息是否填写正确
step 1
检查根目录下的 .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
填写完毕.
stap 2
检查 config 目录下的 database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
]
填写上数据库名,用户名,密码
关闭服务,再开启
不成功的话,你需要把配置的缓存清理掉,再开启服务
// shell
$ php artisan config:clear
$ php artisan serve