Laravel:错误 [PDOException]:无法在 MySQL 中找到驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30529583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: Error [PDOException]: Could not Find Driver in MySQL
提问by Lai32290
I'm trying save a register in my MySQL
database using Eloquent
of Laravel 5
我正在尝试MySQL
使用Eloquent
of在我的数据库中保存一个寄存器Laravel 5
I edited database information in .env
file, localized in my system root path, and in config/database.php
maintain 'default' => 'mysql'
and other mysql connection information (it using env('DB_DATABASE', 'forge')
for get informations)
我在.env
文件中编辑数据库信息,在我的系统根路径中本地化,并在config/database.php
维护'default' => 'mysql'
和其他 mysql 连接信息中(它env('DB_DATABASE', 'forge')
用于获取信息)
I can use Migration
, but when I trying save register using function save()
of my Model
:
我可以使用Migration
,但是当我尝试使用save()
我的功能保存寄存器时Model
:
$newClient = new Client;
$newClient->name = "John";
$newClient->save();
It will occur the fallowing error:
它会发生以下错误:
PDOException in Connector.php line 47:
could not find driver
================================================================ For @user3158900:
================================================== ============== 对于@user3158900:
I think my PHP
has MySQL
extension installed, fallowing my phpinfo()
about Mysql
我想我PHP
已经MySQL
扩展安装,休耕我phpinfo()
约Mysql
>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]
回答by user1669496
If you are using WAMP, your webserver and command line are using different php configurations.
如果您使用 WAMP,您的网络服务器和命令行将使用不同的 php 配置。
Be sure to enable the pdo_mysql extension in both config files or using the WAMP options.
请务必在两个配置文件中或使用 WAMP 选项启用 pdo_mysql 扩展。