gpt4 book ai didi

laravel - "Could not find driver"执行查询时的消息

转载 作者:行者123 更新时间:2023-12-04 18:39:59 26 4
gpt4 key购买 nike

我有一个 Laravel 项目。直到我将 Ubuntu 19.04 更新到 19.10 之前都很好。在 Postman 上测试我的 API 时出现此错误:

"message": "could not find driver (SQL: select * from `users` where `username` = genesis limit 1)",
"exception": "Illuminate\\Database\\QueryException",
"file": "/home/arkhalis/Repos/laravel/safetrade/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 664

之后我尝试运行 Composer在终端上并得到这个输出
PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50

Fatal error: Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50

我也试过运行 composer update并得到与 this question 相同的结果并运行 sudo apt-get install php-mbstring但与我运行 composer 的结果相同终端上的命令。

最佳答案

尝试安装 Laravel 所需的所有扩展。请看here .

如果您使用的是 PHP 7.1,您可以尝试运行此命令:

sudo apt install php7.1 php7.1-fpm php7.1-curl php7.1-mysql php7.1-common php7.1-mbstring php7.1-mcrypt php7.1-xml

或者,如果您使用的是 PHP7.2,则可以运行此命令(没有 mcrypt,因为它已被删除)

sudo apt install php7.2 php7.2-fpm php7.2-curl php7.2-mysql php7.2-common php7.2-mbstring php7.2-xml

如果您遇到错误,可能是您没有添加任何 PHP 存储库。尝试通过 添加这个完整的 PHP 存储库Ondřej Sury .

sudo add-apt-repository ppa:ondrej/php
sudo apt update

更新

由于您使用的是 Ubuntu 19.10 (Eoan),我听说默认情况下它带有 PHP 7.3。所以,也许你可以试试:

sudo apt install php php-fpm php-curl php-mysql php-common php-mbstring php-xml

现在 ondrej/php仍然没有为 19.10 发布任何 PHP 包(因为最近发布了 Ubuntu 19.10)。作者发布软件包需要时间。

关于laravel - "Could not find driver"执行查询时的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58587257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com