首页 > 解决方案 > php artisan migrate 不适用于 Laravel5.4 中的 XAMP

问题描述

我正在使用命令“php artisan migrate”,但它显示错误,因为用户拒绝访问,我的所有迁移都已成功创建,但它们无法在 localhost phpmyadmin 中迁移?

在命令提示符中,我成功创建了迁移,但它们无法在 localhost phpmyadmin 中迁移,我尝试了所有配置设置,但它不起作用。

在 Connection.php 第 647 行:

SQLSTATE[HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:NO)(SQL:select * from information_schema.tables where table_schema = Blog and table_name = migrations)

在 Connector.php 第 68 行:

SQLSTATE [HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:否)

标签: laravelphpmyadminartisan-migrate

解决方案


该错误表示为您的应用指定的数据库登录详细信息不正确。而且您似乎没有在 env 文件中提供 DB_PASSWORD 值。检查登录详细信息(用户名和密码)并确保用户有权访问指定的数据库。

要确认登录详细信息正确无误,请打开终端并运行:( mysql -u DB_USERNAME -p将 DB_USERNAME 替换为您的数据库用户名,例如 root),它会提示输入密码,输入密码(如果有)并按 ENTER。如果一切顺利,您应该会看到如下内容:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18 Homebrew

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

推荐阅读