Laravel: Error [PDOException]: Could not Find Driver in MySQL

偶尔善良 提交于 2020-01-04 14:15:03

问题


I'm trying save a register in my MySQL database using 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)

I can use Migration, but when I trying save register using function save() of my 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:

I think my PHP has MySQL extension installed, fallowing my phpinfo() about 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]

回答1:


If you are using WAMP, your webserver and command line are using different php configurations.

Be sure to enable the pdo_mysql extension in both config files or using the WAMP options.



来源:https://stackoverflow.com/questions/30529583/laravel-error-pdoexception-could-not-find-driver-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!