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

标签 php mysql laravel laravel-artisan

我已将 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 然后执行以下命令:

更改通过 mysql_native_password BY 'yourpassword' 标识的用户 'user'@'address'

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

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

这让我可以运行 php artisan migrate 并且一切都运行良好!

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

相关文章:

php - 如何在PHP中获得前一天

mysql - SQL:根据条件加入和计数

php - 动态且无限制地在laravel中添加字段

php - 连接查询 - 避免 "SET SQL_BIG_SELECTS=1"和超时

php - CakePHP 在远程服务器上显示没有错误的空白页面

php - 字符串在一列中出现多少次

PHP/mySQL - 在关联数组中选择 WHERE 多个值

mysql - 将两次传递给 xargs 的数据放在一行中

php - 我可以在 Laravel 中处理作业超时吗?

php - 带注释的 Laravel 5 中的路由模型绑定(bind)