我已将 Laravel 5.5 项目上传到 centOS7 服务器。现在,当我第一次运行“php artisan migrate”加载数据库表时,遇到以下错误。
这是我的 .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/