Laravel 5 PDOException Could Not Find Driver
You should install PDO on your server.
Edit your php.ini (look at your phpinfo()
, "Loaded Configuration File" line, to find the php.ini file path).
Find and uncomment the following line (remove the ;
character):
;extension=pdo_mysql.so
Then, restart your Apache server.
For more information, please read the documentation.
Laravel: PDOException: could not find driver
You might need to comment out the following in your php.ini file.
;extension=pdo_mysql.so
Taken from this post:
Laravel 5 PDOException Could Not Find Driver
. I think I had to do something exactly like this when setting up laravel on digital ocean.
Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL
Be sure to configure the 'default'
key in app/config/database.php
For postgres, this would be 'default' => 'postgres',
If you are receiving a [PDOException] could not find driver
error, check to see if you have the correct PHP extensions installed. You need pdo_pgsql.so
and pgsql.so
installed and enabled. Instructions on how to do this vary between operating systems.
For Windows, the pgsql
extensions should come pre-downloaded with the official PHP distribution. Just edit your php.ini
and uncomment the lines extension=pdo_pgsql.so
and extension=pgsql.so
Also, in php.ini
, make sure extension_dir
is set to the proper directory. It should be a folder called extensions
or ext
or similar inside your PHP install directory.
Finally, copy libpq.dll
from C:\wamp\bin\php\php5.*\
into C:\wamp\bin\apache*\bin
and restart all services through the WampServer interface.
If you still get the exception, you may need to add the postgres \bin
directory to your PATH
:
- System Properties -> Advanced tab -> Environment Variables
- In 'System variables' group on lower half of window, scroll through and find the
PATH
entry. - Select it and click Edit
- At the end of the existing entry, put the full path to your postgres bin directory. The bin folder should be located in the root of your postgres installation directory.
- Restart any open command prompts, or to be certain, restart your computer.
This should hopefully resolve any problems. For more information see:
- http://php.net/manual/en/install.pecl.windows.php
- http://webcheatsheet.com/php/install_and_configure.php#extsetup
PDOException::(could not find driver) PHP Configuration MySql
Finally was able to figure it out my self. While changing configuration in php.ini file which is in xampp folder I also modified the file in php installed location .ini file. reverting back the changes worked.
PDOException “could not find driver”
You need to have a module called pdo_mysql. Looking for following in phpinfo(),
pdo_mysql
PDO Driver for MySQL, client library version => 5.1.44
Laravel 5.4 on PHP 7.0: PDO Exception - Could not find driver (MySQL)
There's a conflict between the PHP that is used by Apache and the PHP that is linked to the command line. (It happens more often that it should to be honest).
What is typically done is:
which php
This tells you which php will be expecuted when running in the command line. e.g. /usr/bin/php
mv /usr/bin/php /usr/bin/php.old
Then link or copy the correct PHP version to an executable path:
ln -s /path/to/php/bin/php /usr/bin/php
or the following should also work.
cp /path/to/php/bin/php /usr/bin/php
Also suggested if you want to be able to manually install mods:
ln -s /path/to/php/bin/phpize /usr/bin/phpize
ln -s /path/to/php/bin/php-config /usr/bin/php-config
This way your CLI will match your webserver.
Update:
If as noted in this answer if you are using Ubuntu with multiple alternative installations of PHP you can do:
sudo update-alternatives --set php /usr/bin/php<version>
sudo update-alternatives --set phar /usr/bin/phar<version>
sudo update-alternatives --set phar.phar /usr/bin/phar.phar<version>
sudo update-alternatives --set phpize /usr/bin/phpize<version>
sudo update-alternatives --set php-config /usr/bin/php-config<version>
Related Topics
How to Submit Multiple PHP Forms While Each Form Has Its Own Submit Button
Laravel Unique Validation on Multiple Columns
Disable Xampp Redirect Http to Https
How to Redirect to the Same Page in PHP
How to Fetch Data After Selecting from Dropdown List
Sum Values from Column in HTML
Laravel: Display Difference Between Two Dates in Blade
Secure Hash and Salt For PHP Passwords
Send Attachments With PHP Mail()
Replace Preg_Replace() E Modifier With Preg_Replace_Callback
How to Install Imagick/Imagemagick PHP Extension on Windows 7
How to Compare Comma Separated Ids on Left Join
How to Pass a Number With Forward Slash "/" to Codeigniter Controller Using Ajax
How to Not Make Phpmailer Send an Email With Multiple 'To' Addresses
How to Insert Md5 Hash Value in Ms SQL Server
Codeigniter Call to a Member Function Num Rows on Boolean