php pdo could not find driver

pdo sqlite could not find driver. php file not processing

Hi i’m received the could not find driver error when trying to connect to sqlite via a php file. I’ve set permission to 777. PHP Version 5.2.16, i have the module install. any reason why its not finding the driver, also php.ini is showing the extension pdo.so and pdo_mysql.so installed.

PDO support enabled PDO drivers mysql

pdo_mysql

PDO Driver for MySQL, client library version 5.0.92

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

4 Answers 4

I had to actually install the extension, and this is how i did on Ubuntu 16 running PHP 7.1:

sudo apt install php7.1-sqlite3

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

to be enabled, for sqlite:.subscribers.db

And ofcourse this extension in your ext directory

On archlinux i had to do two things:

after that in my php.ini file for me in /etc/php/php.ini i had to uncomment this line:

by removing semicolon.

Dont forget to restart server.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I am using a portable version of PHP on windows, using the inbuilt web server. I found the following steps helped:

Not the answer you’re looking for? Browse other questions tagged php sqlite pdo or ask your own question.

Linked

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40238

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

PostgreSql ‘PDOException’ with message ‘could not find driver’

pdo is working fine with mysql but with pgsql its giving error ‘PDOException’ with message ‘could not find driver’ I’ve installed php5-pgsql package which also includes pdo_pgsql

This package provides a module for PostgreSQL database connections directly from PHP scripts. It also includes the pdo_pgsql module for use with the PHP Data Object extension.

my dsn is pgsql:dbname=DB;host=192.168.0.2 I am using Ubuntu 10.04

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

10 Answers 10

This message means you need to install and or activate postgresql extension in PHP

This solution works for me : To install postgresql extension

after, for activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

To restart apache server if you use apache such as was my case.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

1) Have you enabled pgsql.so in php.ini ( extension=pgsql.so )?

3) How you authenticate your access into Postgresql?

Make sure you’ve uncommented the line that tells php where the Postgres driver is (usually extension=pgsql.so ) in the main php.ini file.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

than set up extension directory!!

and do not forget to restart server after changing the config.

Try to remove semicolon in front of

included in your php.ini file

You can do that from the XAMPP Control Panel.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I had the same problem with another solution. I lost my around 4 hours to solve this problem. Please check the following to solve this problem.

Check php.ini file and remove semicolon from this line

Restart your apache2 server

sudo service apache2 restart

Check if your PDO driver has updated in localhost phpinfo()

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

Here is what I did to solve the problem.

Make sure to restart the Apache server before you try to see the result.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

When you do not have postgresql installed on the same machine that is Apache and PHP; you have to install php-pgsql and don’t have to add extensions in php.ini manually in Linux (in Windows yes), because redundancies are generated and this does not work (checked in error.log ).

Then you can check the existence of the extension enabled automatically in:

Observations: In phpinfo() you will find the directory conf.d/ and the file error.log

then check you have enabled the extensions correctly.

Источник

PDOException “could not find driver”

This is the specific line of code it is referring to:

Is this something to do with my PHP installation?

Searching the internet has not helped, all I get is experts-exchange and examples, but no solutions.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

39 Answers 39

You need to have a module called pdo_mysql. Looking for following in phpinfo(),

The dsn in your code reveals you are trying to connect with the mysql driver. Your error message indicates that this driver is unavailable.

Check that you have the mysql extension installed on your server.

In Ubuntu/Debian you check for the package with:

Install the php5-mysql package if you do not have it.

In Ubuntu/Debian you can use:

Lastly, to get it working, you will need to restart your web-server:

xenial+4). When try to run command sudo apt-get install php-mysql in ubuntu 16.04 with nginx php fpm i also restart the php fpm and then restart the nginx.

Original answer to question is here:

If your phpinfo() is not showing the pdo_sqlite line (in my case, on my Ubuntu Server), you just need to run the lines above and then you’ll be good to go.

For newer versions of Ubuntu that have PHP 7.0 you can get the php-mysql package:

Then restart your server:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I had the same issue. The solution depends on OS. In my case, i have debian, so to solve it:

Install php-mysql and php7.0-mysql

I edited my php.ini locate at /etc/php/7.0/apache2/php.ini

Then restart apache:

This solves my problem

On my Windows machine, I had to give the absolute path to the extension dir in my php.ini:

On Ubuntu just execute

Use similar command on other PHP versions and package managers.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

worked well on ubuntu and php 7

When adding these into your php.ini ensure the php_pdo.dll reference is first before the db drivers dlls otherwise this will also cause this error message too. Add them like this:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

Did you check your php.ini (check for the correct location with phpinfo()) if MySQL and the driver is installed correctly?

For PHP 5.5 on CentOS I fixed this by installing the php55-mysqlnd package.

for Windows 8.1/10 in :\\php.ini file you should uncomment line «extension=pdo_mysql»

Check if extension_dir in php configuration file set correctly. Try to comment/uncomment some extensions and see if it’s reflected on phpinfo(). If it doesn’t then either php config file cannot be loaded (wrong location) extension_dir is commented or set to the wrong location.

In my case my DSN string was incorrect, specifically it did not contain mysql://. I would have expected a different error message, perhaps something like ‘DSN string does not specify driver/protocol.’

Adding mysql:// to the beginning of the DSN string resolved the issue.

I had the same problem during running tests with separate php.ini. I had to add these lines to my own php.ini file:

Notice: Exactly in this order

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I spent the last day trying to figure out why I was getting the following error. I am running Ubuntu 14.04.

The Problem:
I noticed that my PHP-CLI version was running php7.0 but php_info() (the web version) was displaying php 5.5.9. Even though php_info() said pdo was enabled, using the command line (CLI) wasn’t recognizing the pdo_mysql command. It turns out that mysql was enabled for my old version but not the CLI version. All I did was install mysql for php7.0 and it was able to work.

This is what worked:

To check the version:

To install mysql for php7.0

1) make sure your CLI version is the same as your web version
2) If they are different, make sure your CLI version has the mysql plug-in since it doesn’t come with it as a default.

Incorrect installation of PHP was being called

I was experiencing the same problem. And I hope this would help someone who is having a similar issue as me.

Scenario

I created phpinfo.php file in the public folder and run the phpinfo() to look for the location of my php.ini file.

PHP.ini Location = c:\xampp\php\php.ini

Solution
Instead of calling

which gave me this error, I used

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

The problem is a missing php to mysql library. In CentOs i fixed it by running # yum install php-mysql and then restarting apache with # /bin/systemctl restart httpd.service Note that the naming is slightly different from debian/ubuntu based distros, php->php5 and httpd->apache2.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I extremely recommend mysqllnd instead of mysql because of you would have a lot of problems like number converting and bit type evaluates problem with mysql extension.

on ubuntu install mysqllnd with following command:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I just don’t know why it is installed on such a weird path, for me it’s just a bug in the library package installation script in debian 6. I solved the issue by creating a symbolic for all the files under /usr/lib/php5/20090626/ to /usr/lib/php5/ with this command :

Источник

PDO returning error «could not find driver» with a known working DSN

I’m trying to connect to an odbc database via php’s PDO class:

but when I do, I get the error :

Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’ in C:\inetpub\wwwroot\pdoClass.php:7 Stack trace: #0 C:\inetpub\wwwroot\pdoClass.php(7): PDO->__construct(‘odbc:CS_HDZipCo. ‘, ‘demo’, ‘skdemo!’) #1

thrown in C:\inetpub\wwwroot\pdoClass.php on line 7

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I know this particular DSN works because I was able to build another demo file and connect successfully via odbc_connect :

I’ve been digging through the PDO-ODBC documentation as well as other resources online, but I can’t figure out why PHP is unable to find the driver when trying from PDO.

Update

I popped open my phpinfo page to make sure the odbc driver is installed per Marc B’s comment:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

It looks like the driver is installed unless this is a different driver.

Another Update

On further inspection of my phpini per Marc B’s additional comment, it looks like I don’t have the POD ODBC specific driver installed:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

So here, if I had the ODBC driver for pdo installed, odbc would be at the end of the list, correct?

Источник

I have a Laravel 5.4 project on my Ubuntu 14.04 (VPS with Plesk 12.5.30). After creating the database and setted up the .env file with required information I ran php artisan migrate and exceptions were thrown:

[Illuminate\Database\QueryException]
could not find driver (SQL: select * from information_schema.tables where table_schema = pmaramaldb and table_name = migrations)

[PDOException]
could not find driver

My .env file has:

I’ve followed most of the guides to solve this error and there wasn’t any positive results:

Enabling Extension Solution:

The php.ini file is being generated automatically, I guess this is made by Plesk. At the start of the file it says:

; ATTENTION!
;
; DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
; SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

So I’ve tried it anyway. After that I’ve restarted Apache and then tried again. Didn’t work.

Installing php7.0-mysql Solution:

I’ve also tried to install MySQL in case is not:

user@server:/var/www/vhosts$ sudo apt-get install php7.0-mysql

Leyendo lista de paquetes. Hecho

Creando árbol de dependencias

Leyendo la información de estado. Hecho

php7.0-mysql is already the newest version.

0 actualizados, 0 se instalarán, 0 para eliminar y 67 no actualizados.

** SQL Lite Install Solution:**

I’ve also tried as question link says: sudo apt-get install php5-sqlite and the result was:

user@server:/var/www/vhosts/system/maramal.io/etc$ sudo apt-get install php5-sqlite

Leyendo lista de paquetes. Hecho

Creando árbol de dependencias

Leyendo la información de estado. Hecho

php5-sqlite is already the newest version.

0 actualizados, 0 se instalarán, 0 para eliminar y 67 no actualizados.

Composer Dump-autoload Solution:

It didn’t work either. I’ve tried composer dump-autoload and it didn’t work.

PDO support => enabled

PHP Version => 5.6.30-1+deb.sury.org

Copyright (c) 1997-2016 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

11 Answers 11

As an alternative solution be sure you have installed php7-mysql

try to run command below

or, if you want to automatically install the current version

Same problem, ubuntu 17.10, Laravel 5.5.

$ sudo apt install php7.1-pdo php7.1-mysql

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

A nice quick fix, hope this helps

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

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:

This tells you which php will be expecuted when running in the command line. e.g. /usr/bin/php

Then link or copy the correct PHP version to an executable path:

or the following should also work.

Also suggested if you want to be able to manually install mods:

This way your CLI will match your webserver.

If as noted in this answer if you are using Ubuntu with multiple alternative installations of PHP you can do:

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

I had the same scenario you have. I did resolve mine the following:

1) on your terminal, type

this will output your current php.ini configuration file path.

2) edit php.ini using vim or your preferred editor.

note that /etc/php.ini is your path file for your php.ini. it may be different on your machine.

3) find ;extension=php_pdo_mysql.dll and uncomment it by removing semicolon (;)

4) save your php.ini change/s

**5) restart the web server to apply the changes

sudo systemctl restart apache2

**6) Now run your command.

hope this helps for you.

in linux do like that

first check your php version like this :

after you get version number for example i get 7.1 then install like that

and need to restart apache2

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

Your database driver is missing. To solve the probelem

First install the driver

For ubuntu: For mysql database.

You also can search for other database systems.

You also can search for the driver:

You can try these following command

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

Ok I once experienced this error. I don’t know why but it looks like in php 7.3 there is problem in relation to drivers or something there what I did was switch back to php 7.2 and everything worked fine.

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

clear artisan cache

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

php pdo could not find driver. Смотреть фото php pdo could not find driver. Смотреть картинку php pdo could not find driver. Картинка про php pdo could not find driver. Фото php pdo could not find driver

Show the installed modules for each PHP version with the «-m» option string and use the «-i» option string for informations ( example ):

To use the «composer», you would certainly as well use the FULL path of your PHP executable ( example ):

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *