无法创建迁移(Laravel Framework 9.17.0)

发布于 2025-02-11 04:48:10 字数 727 浏览 0 评论 0原文

我想将MySQL数据库连接到没有XAMPP的Laravel项目(使用Ubuntu 22.04)。 我创建了一个名为my_project的数据库,并将其添加到.env文件中

在创建迁移的旁边我使用了工匠命令:PHP工匠迁移。 作为输出,它返回

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = my_database and table_name = migrations and table_type = 'BASE TABLE')

“在此处输入图像描述”

有什么想法我可能做错了什么?

I want to connect the MySQL database to the Laravel project without XAMPP (Using Ubuntu 22.04).
I created a database called my_project and added it to.env file
enter image description here

Up next to create migrations I used artisan command: php artisan migrate.
As an output it returned

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = my_database and table_name = migrations and table_type = 'BASE TABLE')

enter image description here

Any ideas what I might be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌化 2025-02-18 04:48:10

显然,我父亲找到了我问题的答案:D
问题在于仅为Localhost提供数据库用户赠款。
但是,需要授予它,以便可以从任何IP连接。

CREATE USER 'amir'@'%' IDENTIFIED BY 'password';

Apparently, my dad found the answer to my problem :D
problem was in giving my database user grant only for localhost.
However, it needs to be granted so it can be connected from any IP.

CREATE USER 'amir'@'%' IDENTIFIED BY 'password';

enter image description here

您可以尝试通过执行清洁缓存

php artisan config:cache
php artisan config:clear
php artisan cache:clear

You can try cleaning the cache by doing

php artisan config:cache
php artisan config:clear
php artisan cache:clear
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文