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: 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
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.
PDO exception could not find driver in laravel
If you are looking for simple solution, I had same issue & this worked for me..
When you run php artisan from terminal, you invoke php5-cli package.
To run artisan with XAMPP's php you need to use:
/opt/lampp/bin/php artisan migrate
But make sure your /opt/lampp/etc/php.ini is properly configured to enable pdo_mysql
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 Remove All Non Printable Characters in a String
Get Specific Columns Using "With()" Function in Laravel Eloquent
What's the Difference Between Isset() and Array_Key_Exists()
Replacing Accented Characters PHP
"Connect Failed: Access Denied For User 'Root'@'Localhost' (Using Password: Yes)" from PHP Function
How to Solve "Fatal Error: Class 'MySQLi' Not Found"
Why Is the Hash Part of the Url Not Available on the Server Side
How to Get Count of Rows in MySQL Table Using PHP
PHP - How to Create a Newline Character
Are PHP Variables Passed by Value or by Reference
How to Extend a Class Using More Than 1 Class in PHP
Checking If Form Has Been Submitted - PHP
How to Remove Accents and Turn Letters into "Plain" Ascii Characters