gpt4 book ai didi

php - Laravel:错误 [PDOException]:无法在 MySQL 中找到驱动程序

转载 作者:搜寻专家 更新时间:2023-10-30 20:17:32 25 4
gpt4 key购买 nike

我正在尝试使用 Laravel 5Eloquent 在我的 MySQL 数据库中保存一个寄存器

我在 .env 文件中编辑了数据库信息,本地化在我的系统根路径中,并在 config/database.php 中维护 'default' => ' mysql' 和其他 mysql 连接信息(它使用 env('DB_DATABASE', 'forge') 获取信息)

我可以使用 Migration,但是当我尝试使用 Model 的函数 save() 保存寄存器时:

$newClient = new Client;
$newClient->name = "John";
$newClient->save();

会出现如下错误:

PDOException in Connector.php line 47:
could not find driver

enter image description here

============================================= =================对于@user3158900:

我认为我的 PHP 安装了 MySQL 扩展,允许我的 phpinfo() 关于 Mysql

enter image description here

>php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
imap
json
ldap
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
odbc
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
pdo_sqlsrv
Phar
Reflection
session
SimpleXML
soap
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

最佳答案

如果您使用的是 WAMP,则您的网络服务器和命令行使用不同的 PHP 配置。

确保在两个配置文件或使用 WAMP 选项中启用 pdo_mysql 扩展。

关于php - Laravel:错误 [PDOException]:无法在 MySQL 中找到驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30529583/

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