我尝试运行:php artisan migrate
还有使用 Windows 上的 Xampp 连接到 MySQL。
我遇到了这个错误:
Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access
denied for user ''@'localhost' to database 'homestead' (SQL: select *
from information_schema.tables where table_schema = homestead and
table_name = migrations)
at
C:\Users\harsh\Laravel1\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668| Exception trace:
1 PDOException::("SQLSTATE[HY000] [1044] Access denied for user
''@'localhost' to database 'homestead'")
C:\Users\harsh\Laravel1\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
2
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead",
"homestead", "", [])
C:\Users\harsh\Laravel1\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
Please use the argument -v to see more details.
.env 文件:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=
.env
文件中,并在项目根目录的控制台中运行php artisan cache:clear
。 - Hilmi Erdem KERENconfig/database.php
和.env
文件里有什么内容?(别忘了删除密码!) - Jerodevhomestead
的数据库和用户? - Jerodevsecret
。 - Hilmi Erdem KEREN