我已将Laravel 5.5项目上传到centOS7服务器。现在,当我第一次运行“php artisan migrate”加载数据库表时,我面临以下错误。
这是我的.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]
答案 0 :(得分:2)
我所做的确实很好,只是改变了root用户的密码。在终端上登录mysql,然后执行以下命令:
ALTER USER 'user'@'address' IDENTIFIED WITH mysql_native_password BY 'yourpassword'
对于该用户,我使用了'root'@'localhost'
,您可能想使用其他用户。
然后,用您在上面的命令中选择的密码替换DB_PASSWORD=yourpassword
并保存文件。
这使我能够运行php artisan migrate
,一切正常!