laravel - Laravel 无法加载动态库 'pdo_mysql.so'
问题描述
我有一个 Laravel 项目,我需要进行一些维护,所以我克隆了该项目,运行composer update
然后尝试迁移php artisan migrate
(在 MySQL 上创建数据库之后)...
我在 Ubuntu 20.04 上,使用 PHP 7.4 和 Laravel 8。
我收到此错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = escola_da_qualidade and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:685
681▕ // If an exception occurs when attempting to run a query, we'll format the error
682▕ // message to include the bindings with SQL, which will make this exception a
683▕ // lot more helpful to the developer instead of just the database's errors.
684▕ catch (Exception $e) {
➜ 685▕ throw new QueryException(
686▕ $query, $this->prepareBindings($bindings), $e
687▕ );
688▕ }
689▕
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
在 Stackoverflow 上搜索,我尝试使用 , 等安装apt-get install php-mysql
库apt-get install php7.4-mysql
...
这是结果php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
imap
intl
json
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
我也尝试extension=pdo_mysql
在 /etc/php/7.4/apache2/php.ini 以及 /etc/php/7.4/cli/php.ini 中取消注释,然后重新启动 apache2,但仍然出现相同的错误。
laravel config/database.php 上的默认驱动程序是'default' => env('DB_CONNECTION', 'mysql'),
和 .env 我有DB_CONNECTION=mysql
也试过php artisan config:cache
了php artisan config:clear
有什么帮助吗?
解决方案
推荐阅读
- qt - 用于绘制数据的 Qt:截取窗口然后关闭窗口
- django - 在不接触模板的情况下使用引导程序拥有外部 django 应用程序?
- reactjs - React Native - 我似乎无法让 Axios 和 AsyncStorage 在 Android 中一起工作,但代码在 iOS 上工作?
- c# - 实现接口的实体的通用配置
- mysql - mysql数据过滤
- python - glob 与 if 语句来选择哪些文件存储到一个变量?
- sql-server - SQL Server:安全地将数据移动到(维护不善的)历史表
- https - 我想把 kibana 带到 https 上。有什么方法可以做到
- python - 在 PyQt4 中动态创建/填充 QTableWidgets
- angular - 使用 null 过滤