【发布时间】:2019-06-05 01:29:04
【问题描述】:
我尝试运行: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。 -
您的
config/database.php和.env文件中有什么内容? (不要忘记删除密码!) -
@Jerodev 我删除了密码,并使用 .env 的其他详细信息进行了编辑,但仍然无法解决我的问题。
-
@HilmiErdemKEREN 我已经添加了 .env 连接详细信息,仍然无法解决问题,请查看问题所在。
-
你是否真的创建了一个名为
homestead的数据库和用户?
标签: php mysql laravel laravel-5