artisan migrate为新项目显示服务器错误

eblbsuwk  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(397)

我已将我的Laravel5.5项目上载到centos7服务器。现在,当我第一次运行“php artisan migrate”来加载数据库表时,我遇到了以下错误。
错误消息屏幕截图
这是我的.env db部分

  1. DB_CONNECTION=mysql
  2. DB_HOST=127.0.0.1
  3. DB_PORT=3306
  4. DB_DATABASE=event
  5. DB_USERNAME=root
  6. DB_PASSWORD=testpass

我已经在mysql中创建了db。

  1. [root@li129-226 event_management]# php artisan migrate
  2. In Connection.php line 664:
  3. 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)
  4. In Connector.php line 67:
  5. SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
  6. In Connector.php line 67:
  7. PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
uyto3xhc

uyto3xhc1#

我所做的非常好的工作就是将root用户修改为拥有密码。在终端上登录mysql,然后执行以下命令: ALTER USER 'user'@'address' IDENTIFIED WITH mysql_native_password BY 'yourpassword' 对于用户,我使用 'root'@'localhost' 您可能需要使用其他用户。
然后,更换 DB_PASSWORD=yourpassword 使用您在上述命令中选择的密码并保存文件。
让我可以跑了 php artisan migrate 一切都太好了!

相关问题