【问题标题】:Artisan migrate showing error in the server for a fresh project工匠迁移在新项目的服务器中显示错误
【发布时间】:2018-10-13 08:40:03
【问题描述】:

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

Error message screenshot

这是我的 .env db 部分

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]

【问题讨论】:

标签: php mysql laravel laravel-artisan


【解决方案1】:

我所做的非常有效的只是将 root 用户更改为拥有密码。在终端上登录 mysql 然后执行以下命令:

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

对于用户,我使用了'root'@'localhost' 您可能想要使用其他用户。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-17
    • 2017-06-20
    • 2014-06-01
    • 2016-06-16
    • 1970-01-01
    • 2017-11-29
    • 1970-01-01
    • 2016-05-22
    相关资源
    最近更新 更多