gpt4 book ai didi

php - Artisan 迁移显示服务器中新项目的错误

转载 作者:行者123 更新时间:2023-11-29 01:49:36 27 4
gpt4 key购买 nike

我已经将我的 Laravel 5.5 项目上传到 centOS7 服务器。现在,当我第一次运行“php artisan migrate”加载数据库表时,我遇到了以下错误。

Error message screenshot

这是我的 .env 数据库部分

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=event
DB_USERNAME=root
DB_PASSWORD=testpass

我已经在 MySQL 中创建了数据库。

[root@li129-226 event_management]# php artisan migrate

In Connection.php line 664:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = event and table_name = migrations)

In Connector.php line 67:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

In Connector.php line 67:
PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]

最佳答案

我所做的非常有效的是只改变 root 用户以获得密码。在终端上登录到 mysql,然后执行以下命令:

ALTER USER 'user'@'address' IDENTIFIED WITH mysql_native_password BY 'yourpassword'

对于用户,我使用了 'root'@'localhost' 您可能想要使用不同的用户。

然后,将 DB_PASSWORD=yourpassword 替换为您在上述命令中选择的密码并保存文件。

这让我可以运行 php artisan migrate 并且一切正常!

关于php - Artisan 迁移显示服务器中新项目的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50148156/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com