I have just installed Debian Lenny with Apache, MySQL, and PHP and I am receiving a PDOException could not find driver
.
This is the specific line of code it is referring to:
$dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS)
DB_HOST
, DB_NAME
, DB_USER
, and DB_PASS
are constants that I have defined. It works fine on the production server (and on my previous Ubuntu Server setup).
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.
ghbarratt
11.3k4 gold badges40 silver badges41 bronze badges
asked May 17, 2010 at 20:57
8
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
answered May 17, 2010 at 21:33
ZZ CoderZZ Coder
73.8k29 gold badges135 silver badges168 bronze badges
10
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:
dpkg --get-selections | grep php | grep mysql
Install the php5-mysql package if you do not have it.
In Ubuntu/Debian you can use:
- PHP5:
sudo apt-get install php5-mysql
- PHP7:
sudo apt-get install php7.0-mysql
Lastly, to get it working, you will need to restart your web-server:
- Apache:
sudo /etc/init.d/apache2 restart
- Nginx:
sudo /etc/init.d/nginx restart
answered Nov 10, 2011 at 5:21
ghbarrattghbarratt
11.3k4 gold badges40 silver badges41 bronze badges
2
Update: newer versions should use php-sqlite3
package instead of php5-sqlite
. So use this, if you are using a recent ubuntu version:
sudo apt-get install sqlite php-sqlite3
Original answer to question is here:
sudo apt-get install sqlite php5-sqlite
sudo /etc/init.d/apache2 restart
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.
answered Aug 27, 2010 at 18:39
8
For newer versions of Ubuntu that have PHP 7.0 you can get the php-mysql
package:
sudo apt-get install php-mysql
Then restart your server:
sudo service apache2 restart
answered Aug 19, 2016 at 6:28
ThomasAFinkThomasAFink
1,16412 silver badges25 bronze badges
1
I had the same issue. The solution depends on OS. In my case, i have debian, so to solve it:
- Updated my php version from (php5 to php7)
-
Install php-mysql and php7.0-mysql
apt-get install php-mysql apt-get install php7.0-mysql
-
I edited my
php.ini
locate at /etc/php/7.0/apache2/php.iniuncomment the line : extension=php_pdo_mysql.dll
-
Then restart apache:
service apache2 restart
This solves my problem
answered Jun 5, 2017 at 1:26
onlymeonlyme
3,6142 gold badges22 silver badges16 bronze badges
1
On my Windows machine, I had to give the absolute path to the extension dir in my php.ini:
extension_dir = "c:php5ext"
fvrghl
3,5825 gold badges27 silver badges36 bronze badges
answered Jun 10, 2013 at 22:41
berdziberdzi
2412 silver badges2 bronze badges
2
Check if the module is available with php -m | grep pdo_mysql
.
If not, for PHP 7.2, you can install relevant package with sudo apt install php7.2-mysql
.
Use similar command on other PHP versions and package managers.
answered Jul 4, 2019 at 5:30
PratikPratik
9091 gold badge13 silver badges20 bronze badges
On Ubuntu just execute
sudo apt-get install php5-mysql
answered Apr 16, 2013 at 13:22
2
sudo apt-get install php-mysql
worked well on ubuntu and php 7
answered May 12, 2016 at 9:11
1
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]
extension=php_pdo.dll
[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
Luís Cruz
14.6k16 gold badges69 silver badges98 bronze badges
answered Nov 17, 2014 at 23:33
1
for Windows 8.1/10 in :\php.ini file you should uncomment line «extension=pdo_mysql»
answered Dec 19, 2017 at 16:18
Did you check your php.ini (check for the correct location with phpinfo()) if MySQL and the driver is installed correctly?
answered May 17, 2010 at 21:08
cemcem
3,2911 gold badge17 silver badges23 bronze badges
1
For PHP 5.5
on CentOS
I fixed this by installing the php55-mysqlnd
package.
sudo yum -y install php55w-mysqlnd # For Webtatic
sudo yum -y install php55u-mysqlnd # For Remi
For help installing, write a comment as it depends on the way PHP is installed on your system. Available repo’s are webtatic
and remi
.
answered Jul 23, 2014 at 9:22
SimonWSimonW
6,0454 gold badges31 silver badges38 bronze badges
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.
answered Aug 18, 2012 at 14:02
hsergehserge
8951 gold badge9 silver badges12 bronze badges
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.
answered Jun 21, 2012 at 16:38
I had the same problem during running tests with separate php.ini. I had to add these lines to my own php.ini file:
[PHP]
extension = mysqlnd.so
extension = pdo.so
extension = pdo_mysql.so
Notice: Exactly in this order
answered Jul 23, 2016 at 15:04
FacedownFacedown
1821 gold badge2 silver badges10 bronze badges
0
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:
php -v
To install mysql for php7.0
sudo apt-get install php7.0-mysql
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.
answered Jan 4, 2017 at 20:31
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
OS = Windows 10
Platform = XAMPP
PHP Version = 7 (Multiple Version seem to have been installed in the PC)
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:xamppphpphp.ini
Problem
Calling c:xampphtdocs> php -v
returned PHP 7.2.3
but phpinfo.php
showed PHP 7.2.2
.
Solution
Instead of calling
php artisan migrate:install
which gave me this error, I used
c:xamppphpphp artisan migrate:install
and it worked.
answered Sep 21, 2018 at 10:21
RealSollyMRealSollyM
1,5201 gold badge23 silver badges35 bronze badges
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.
answered Dec 8, 2015 at 6:36
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:
sudo apt-get install php5-mysqlnd
answered Sep 17, 2016 at 17:21
MSSMSS
3,47024 silver badges28 bronze badges
In my case, I was using PDO with php-cli, and it worked fine.
Only when I tried to connect from apache, I got the «missing driver» issue, which I didn’t quite understand.
A simple apt-get install php-mysql
solved it. (Ubuntu 16.04 / PHP7. credits go to the selected answer & Ivan’s comment)
Hope it can help.
answered Oct 31, 2016 at 14:46
BalmipourBalmipour
2,9351 gold badge23 silver badges27 bronze badges
PHP Fatal error: Uncaught PDOException: could not find driver
I struggled and struggled with «apt install php-mysql php7toInfinity and don’t forget sqlite-what-ever’s» and just could not get rid of this error message until I went back to basics and reset the file-permissions on the web-site in question.
These 3 commands reset file and folder permissions on the web-site and got it to work again.
cd /var/www/web-site-name.com/web/
# find (sub) directories and change permissions
find . -type d -exec chmod 755 {} ;
# find files and change permissions
find . -type f -exec chmod 664 '{}' ;
answered Aug 18, 2019 at 18:48
SamTzuSamTzu
1671 silver badge6 bronze badges
I Fixed this issue on my Debian 6.
Normally I just had installed php5-common
package. After installation, you have to restart your web server (apache or nginx depending on which one you installed).
Then I just do an lsof
on the apache process id (lsof -p process_id
) as followed :
sudo lsof -p 1399 #replace 1399 by your apache process id
apache2 1399 root mem REG 254,2 80352 227236 /usr/lib/php5/20090626/xmlrpc.so
apache2 1399 root mem REG 254,2 166496 227235 /usr/lib/php5/20090626/suhosin.so
apache2 1399 root mem REG 254,2 31120 227233 /usr/lib/php5/20090626/pdo_mysql.so
apache2 1399 root mem REG 254,2 100776 227216 /usr/lib/php5/20090626/pdo.so
apache2 1399 root mem REG 254,2 135864 227232 /usr/lib/php5/20090626/mysqli.so
As you can see above, the modules are installed on a file path not known or guided by common library path: /usr/lib/php5/20090626/
. For your installation, it may be different, but only the path of pdo_mysql.so, pdo.so, mysqli.so. So, this is why Drupal or any other php engine couldn’t find the library and shows that error: PDOException: 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 :
ln -s /usr/lib/php5/20090626/* /usr/lib/php5/
fvrghl
3,5825 gold badges27 silver badges36 bronze badges
answered Nov 8, 2012 at 17:20
douggynixdouggynix
1412 silver badges2 bronze badges
1
$DB_TYPE = 'mysql'; //Type of database<br>
$DB_HOST = 'localhost'; //Host name<br>
$DB_USER = 'root'; //Host Username<br>
$DB_PASS = ''; //Host Password<br>
$DB_NAME = 'database_name'; //Database name<br><br>
$dbh = new PDO("$DB_TYPE:host=$DB_HOST; dbname=$DB_NAME;", $DB_USER, $DB_PASS); // PDO Connection
This worked for me.
fvrghl
3,5825 gold badges27 silver badges36 bronze badges
answered Jun 3, 2013 at 3:18
1
I faced the same issue after I removed the php5 package (that includes all the drivers as well) in order to install php7 package. I actually installed php7 package without a mysql module.
I managed to solve it by typing in the terminal:
1) $ apt-cache search php7
which lists all the modules, looking through the modules I found,
php7.0-mysql — MySQL module for PHP
2) $ sudo apt-get install php7.0-mysql
That’s it. It worked for me in my linux system.
(use the appropriate php version, yours could be php5)
answered May 10, 2016 at 12:38
RoshimonRoshimon
1,96118 silver badges16 bronze badges
Just one other thing to confirm as some people are copy/pasting example code from the Internet to get started. Make sure you have MySQL entered here:
... $dbh = new PDO ("mysql: ...
In some examples this shows
$dbh = new PDO ("dblib ...
Dimitar
4,2594 gold badges32 silver badges46 bronze badges
answered Jun 29, 2016 at 3:49
For those using Symfony2/3 and wondering why you’re getting this error. If you’re using «mapping_types», you might encounter this error. The reason is that «mapping_types» is placed at the wrong level. For instance :
doctrine:
dbal:
mapping_types:
set: string
This «mapping_types» must be placed at this level :
doctrine:
dbal:
#To counter the error caused by 'mapping_types'
connections:
default:
server_version: %database_server_version%
mapping_types:
set: string
I hope this helps
I found the solution here : https://github.com/doctrine/DoctrineBundle/issues/327
answered Feb 17, 2017 at 20:07
aneth101aneth101
4894 silver badges9 bronze badges
Everywhere I go I read that the path of extension_dir
should be changed from ext
to an absolute path. It worked for me. However, when trying to build a server of my colleague’s PC, I had to let the value to ext
instead of putting an absolute path.
If you did put an absolute path and it does the extension is still not found, considerer trying both with the absolute path and ext
.
answered Feb 13, 2018 at 10:42
papillonpapillon
1,5982 gold badges16 silver badges34 bronze badges
Check correct path in extension_dir in you phpinfo().
answered May 29, 2019 at 19:42
Had the same issue, because I forgot to go into my virtual machine. If I go to my local directory like this:
cd /www/homestead/my_project
php artisan migrate
that error will appear. But it works on my virtual machine
cd ~/homestead
vagrant ssh
cd /www/homestead/my_project
php artisan migrate
answered Jun 21, 2019 at 7:16
AdamAdam
23.9k21 gold badges143 silver badges228 bronze badges
I am developing a website on a server I only have access to MySQL and FTP, so all commands I run are through the b374k php shell . I am experiencing a Laravel problem with SQL driver. I tried switching to file-hosted SQLite (in database/database.sqlite), but the thrown exception is the same as when using MySQL. The input & output of the console is as follows:
php artisan migrate:refresh --seed
[IlluminateDatabaseQueryException]
could not find driver (SQL: select * from sqlite_master where type = 'table ' and name = migrations)
[DoctrineDBALDriverPDOException]
could not find driver
[PDOException]
could not find driver
The Apache extensions installed on the server are:
/etc/php/5.6/apache2/conf.d/10-mysqlnd.ini,
/etc/php/5.6/apache2/conf.d/10-opcache.ini,
/etc/php/5.6/apache2/conf.d/10-pdo.ini,
/etc/php/5.6/apache2/conf.d/15-xml.ini,
/etc/php/5.6/apache2/conf.d/20-calendar.ini,
/etc/php/5.6/apache2/conf.d/20-ctype.ini,
/etc/php/5.6/apache2/conf.d/20-curl.ini,
/etc/php/5.6/apache2/conf.d/20-dom.ini,
/etc/php/5.6/apache2/conf.d/20-exif.ini,
/etc/php/5.6/apache2/conf.d/20-fileinfo.ini,
/etc/php/5.6/apache2/conf.d/20-ftp.ini, /etc/php/5.6/apache2/conf.d/20-gd.ini,
/etc/php/5.6/apache2/conf.d/20-gettext.ini,
/etc/php/5.6/apache2/conf.d/20-iconv.ini,
/etc/php/5.6/apache2/conf.d/20-json.ini,
/etc/php/5.6/apache2/conf.d/20-mbstring.ini,
/etc/php/5.6/apache2/conf.d/20-mcrypt.ini,
/etc/php/5.6/apache2/conf.d/20-mysql.ini,
/etc/php/5.6/apache2/conf.d/20-mysqli.ini,
/etc/php/5.6/apache2/conf.d/20-pdo_mysql.ini,
/etc/php/5.6/apache2/conf.d/20-phar.ini,
/etc/php/5.6/apache2/conf.d/20-posix.ini,
/etc/php/5.6/apache2/conf.d/20-readline.ini,
/etc/php/5.6/apache2/conf.d/20-shmop.ini,
/etc/php/5.6/apache2/conf.d/20-simplexml.ini,
/etc/php/5.6/apache2/conf.d/20-sockets.ini,
/etc/php/5.6/apache2/conf.d/20-sysvmsg.ini,
/etc/php/5.6/apache2/conf.d/20-sysvsem.ini,
/etc/php/5.6/apache2/conf.d/20-sysvshm.ini,
/etc/php/5.6/apache2/conf.d/20-tokenizer.ini,
/etc/php/5.6/apache2/conf.d/20-wddx.ini,
/etc/php/5.6/apache2/conf.d/20-xmlreader.ini,
/etc/php/5.6/apache2/conf.d/20-xmlwriter.ini,
/etc/php/5.6/apache2/conf.d/20-xsl.ini,
/etc/php/5.6/apache2/conf.d/20-zip.ini
What can be the problem and how can I fix it? (I don’t have access to root bash)
Today We are Going To Solve Laravel PDOException could not find driver in laravel. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.
How to Fix Laravel PDOException could not find driver Error?
- How to Fix Laravel PDOException could not find driver Error?
To Fix Laravel PDOException could not find driver Error just Find
php.ini
path viaphpinfo()
. To solve this error just follow the below steps
First of all findphp.ini
path viaphpinfo()
And then uncomment the line textension=php_pdo_mysql.dll
from your code. And add this line to your codeextension=pdo_mysql.so
And at the last just runsudo apt-get install php-mysql
And your error will be removed. Try that. - Laravel PDOException could not find driver
To Fix Laravel PDOException could not find driver Error just Run the command. You can fix your issue by just running the below command:
composer update composer require doctrine/dbal
Solution 1 : Find php.ini
path via phpinfo()
To solve this error just follow the below steps
- First of all find
php.ini
path viaphpinfo()
- And then uncomment the line t
extension=php_pdo_mysql.dll
from your code. - And add this line to your code
extension=pdo_mysql.so
- And at the last just run
sudo apt-get install php-mysql
And your error will be removed. Try that.
Solution 2 : Run the command
You can fix your issue by just running the below command:
composer update
composer require doctrine/dbal
Conclusion
So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.
Also Read This Solutions
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11
- function ‘Rcpp_precious_remove’ not provided by package ‘Rcpp’
- Getting “TypeError: Failed to fetch” when the request hasn’t actually failed
- This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
- Gradle plugin requires Java 11 to run. You are currently using Java 1.8
@meet-bhagdev
Thanks for your response.
[root@dev ~]# odbcinst -q -d -n «ODBC Driver 13 for SQL Server»
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
Threading=1
UsageCount=2
[root@dev ~]# php -m
[PHP Modules]
……
PDO
pdo_mysql
PDO_OCI
PDO_ODBC
pdo_sqlite
pdo_sqlsrv
……
sqlsrv
……
[Zend Modules]
Zend OPcache
[root@dev ~]# php -v
PHP 7.0.9 (cli) (built: Aug 8 2016 12:22:02) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies
[root@dev ~]# php -i
……
PDO
PDO support => enabled
PDO drivers => oci, odbc, sqlite, mysql, sqlsrv
……
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled
ODBC Connection Pooling => Enabled, strict matching
……
pdo_sqlsrv
pdo_sqlsrv support => enabled
ExtensionVer => 4.0.2.0
Directive => Local Value => Master Value
pdo_sqlsrv.client_buffer_max_kb_size => 10240 => 10240
pdo_sqlsrv.log_severity => 0 => 0
……
sqlsrv
sqlsrv support => enabled
ExtensionVer => 4.0.2.0
Directive => Local Value => Master Value
sqlsrv.ClientBufferMaxKBSize => 10240 => 10240
sqlsrv.LogSeverity => 0 => 0
sqlsrv.LogSubsystems => 0 => 0
sqlsrv.WarningsReturnAsErrors => On => On
……
[root@dev ~]# cat /web/test.php
«;
} catch ( PDOException $e ) {
echo ‘The connection failed: ‘ . $e->getMessage ();
}
?>
result:
The connection failed: could not find driver.
[root@dev ~]# cat /usr/local/php/etc/php.ini
……
date.timezone = PRC
include_path = «/usr/local/php/lib/php»
extension=php_sqlsrv_7_nts.so
extension=php_pdo_sqlsrv_7_nts.so
zend_extension=opcache.so
Configure Command:
./buildconf —force
./configure LIBS=-lodbc
—prefix=/usr/local/php
—with-apxs2=/usr/local/httpd/bin/apxs
—with-config-file-path=/usr/local/php/etc
—enable-pdo
—with-mysqli=/usr/local/mysql/bin/mysql_config
—with-pdo-mysql=mysqlnd
—with-pdo-oci=instantclient,/usr,12.1.0.2
—with-oci8=instantclient,/usr/lib/oracle/12.1/client64/lib,12.1.0.2
—with-unixODBC=/usr
—with-pdo-odbc=unixODBC,/usr
—with-sqlite3
—with-pdo-sqlite
—with-iconv=/usr/local/libiconv
—with-zlib=/usr/local/zlib
—with-zlib-dir=/usr/local/zlib
—with-openssl=/usr/local/ssl
—with-pcre-dir=/usr/local/pcre
or
./buildconf —force
./configure LIBS=-lodbc
—prefix=/usr/local/php
—with-apxs2=/usr/local/httpd/bin/apxs
—with-config-file-path=/usr/local/php/etc
—enable-pdo=shared
—with-mysqli=/usr/local/mysql/bin/mysql_config
—with-pdo-mysql=shared,mysqlnd
—enable-mysqlnd
—with-sqlite3=shared,/usr/local/sqlite3
—with-pdo-sqlite=shared,/usr/local/sqlite3
—with-pdo-oci=shared,instantclient,/usr,12.1.0.2
—with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib,12.1.0.2
—with-unixODBC=shared,/usr
—with-pdo-odbc=shared,unixODBC,/usr
—with-iconv=/usr/local/libiconv
—with-zlib=/usr/local/zlib
—with-zlib-dir=/usr/local/zlib
—with-openssl=/usr/local/ssl
—with-pcre-dir=/usr/local/pcre
[root@dev ~]# httpd -V
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 01:24:13
Server’s Module Magic Number: 20120211:61
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with….
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT=»/usr/local/httpd»
-D SUEXEC_BIN=»/usr/local/httpd/bin/suexec»
-D DEFAULT_PIDLOG=»logs/httpd.pid»
-D DEFAULT_SCOREBOARD=»logs/apache_runtime_status»
-D DEFAULT_ERRORLOG=»logs/error_log»
-D AP_TYPES_CONFIG_FILE=»conf/mime.types»
-D SERVER_CONFIG_FILE=»conf/httpd.conf»
The test URL:
http://i-up.vicp.cc/info.php
http://i-up.vicp.cc/pdo-test.php
Compiled into static or dynamic modules can not solve this problem.
The problem has been bothering me for a lot of days. Hope to get your help.thanks.
-
santex85
- Сообщения: 2
- Зарегистрирован: 18 апр 2016, 12:27
-
Максим
- Сообщения: 5993
- Зарегистрирован: 11 дек 2010, 20:29
-
orogastus
- Сообщения: 3
- Зарегистрирован: 23 янв 2015, 21:35
Re: Ошибка Uncaught exception ‘PDOException’ with message ‘could not find driver’
Непрочитанное сообщение
orogastus » 10 сен 2018, 09:45
Вот такая ошибка вылазит:
Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’ in C:OSPaneldomainsC9includesetting.php:9 Stack trace: #0 C:OSPaneldomainsC9includesetting.php(9): PDO->__construct(‘sqlsrv:server=8…’, ‘sa’, ‘m128634!’) #1 C:OSPaneldomainsC9script-head.php(3): include_once(‘C:OSPaneldoma…’) #2 C:OSPaneldomainsC9index.php(1): include(‘C:OSPaneldoma…’) #3 {main} thrown in C:OSPaneldomainsC9includesetting.php on line 9
скриншот: все подключено раскомментировано: http://prntscr.com/kskl0e
помогите, куда копать?
include_once(«function.php»);
$sql = new PDO(«sqlsrv:server=».MSSQL_HOST.»; Database=».MSSQL_DB.»»,MSSQL_USER,MSSQL_PASS);
$api = new API(true);
$ip = $_SERVER[‘REMOTE_ADDR’];
вот что там
-
orogastus
- Сообщения: 3
- Зарегистрирован: 23 янв 2015, 21:35
-
Максим
- Сообщения: 5993
- Зарегистрирован: 11 дек 2010, 20:29
Re: Ошибка Uncaught exception ‘PDOException’ with message ‘could not find driver’
Непрочитанное сообщение
Максим » 07 сен 2021, 18:47
voron121, вы ничего не можете понять, т.к. не читали или невнимательно прочитали руководство пользователя. В противном случае вы могли бы знать, что корректная среда окружения доступна только в тех программах, что запускаются из меню Open Server. А когда вы запускаете свои обычные программы в Windows они естественно не видят переменные окружения Open Server и вы получаете то, что получаете.
На будущее, предвидя ваше следующее непонимание, замечу, что если вы меняете версию любого модуля в настройках, то меняется и окружение. Поэтому программы, запущенные из меню ранее, необходимо перезапускать, чтобы они увидели обновлённое окружение. Всё это указано в руководстве.
I woork on my local site with MAMP. Everything was going right till yesterday. Now, when I run my code, I get a : «Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’…» It seems that I have non installed driver but it worked well until this day. How can I fix this problem ?
Best,
Newben
Firas Assaad
24.6k16 gold badges61 silver badges78 bronze badges
asked Jun 6, 2012 at 10:01
2
Have you installed MacPorts? If your answer is «yes» open your Shell and type:
cd ~/
sudo nano .profile
-
change:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
replace with:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php5.3.6/bin/:$PATH
-
close your Shell and re-open it
This is all. I found the solution here: thewebfactory
answered Jun 10, 2012 at 16:20
SfblaauwSfblaauw
1,51618 silver badges21 bronze badges
1
I had a similar problem. Sfblaauw’s solution didn’t work but it helped me identify the problem. First I installed php5-mysql using MacPorts:
sudo port install php5-mysql
During installation, I got the following warning:
Your php.ini contains a line that will prevent php5-mysql
and other PHP extensions from working. To fix this,
edit /opt/local/etc/php5/php.ini and delete this line:extension_dir = «/usr/lib/php/extensions/no-debug-non-zts-20090626»
I commented out the line and restarted Apache. Everything seems to work fine now.
answered Feb 6, 2013 at 15:07
Firas AssaadFiras Assaad
24.6k16 gold badges61 silver badges78 bronze badges
I woork on my local site with MAMP. Everything was going right till yesterday. Now, when I run my code, I get a : «Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’…» It seems that I have non installed driver but it worked well until this day. How can I fix this problem ?
Best,
Newben
Firas Assaad
24.6k16 gold badges61 silver badges78 bronze badges
asked Jun 6, 2012 at 10:01
2
Have you installed MacPorts? If your answer is «yes» open your Shell and type:
cd ~/
sudo nano .profile
-
change:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
replace with:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php5.3.6/bin/:$PATH
-
close your Shell and re-open it
This is all. I found the solution here: thewebfactory
answered Jun 10, 2012 at 16:20
SfblaauwSfblaauw
1,51618 silver badges21 bronze badges
1
I had a similar problem. Sfblaauw’s solution didn’t work but it helped me identify the problem. First I installed php5-mysql using MacPorts:
sudo port install php5-mysql
During installation, I got the following warning:
Your php.ini contains a line that will prevent php5-mysql
and other PHP extensions from working. To fix this,
edit /opt/local/etc/php5/php.ini and delete this line:extension_dir = «/usr/lib/php/extensions/no-debug-non-zts-20090626»
I commented out the line and restarted Apache. Everything seems to work fine now.
answered Feb 6, 2013 at 15:07
Firas AssaadFiras Assaad
24.6k16 gold badges61 silver badges78 bronze badges
I have launched my Symfony project in browser but I have this problem in error.log
[:error] [pid 4789] [client ::1:39684] PHP Fatal error: Uncaught exception
'PDOException' with message 'could not find driver' in /var/www/html/ensoSteps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43nStack trace:n#0 /var/www/html/ensoSteps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('sqlite:/var/www...', NULL, NULL, Array)n#1 /var/www/html/ensoSteps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php(60): DoctrineDBALDriverPDOConnection->__construct('sqlite:/var/www...', NULL, NULL, Array)n#2
/var/www/html/ensoSteps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360):DoctrineDBALDriverPDOSqliteDriver->connect(Array, NULL, NULL, Array)n#3 /var/www/html/ensoSteps/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1365): DoctrineDBALConnection->connect()n#4
/var/www/html/ensoSteps/vendor/jackalope/jackalope-doctrine-dbal/src/Jackalope/Transport/DoctrineDBAL/Client.php(2619): DoctrineDBALConnection->getWrappedConnection()n#5
/var/www/html/ensoSteps/vendor/jackalope/jack in
/var/www/html/ensoSteps/vendor/jackalope/jackalope-doctrine-dbal/src/Jackalope/Transport/DoctrineDBAL/Client.php on line 460
Help me please for solved this problem.
asked Mar 28, 2017 at 12:37
I’ve never used Symfony but it looks like you’re missing the SQLite driver for the PDO (PHP Database Objects) extension.
This is provided by the php5-sqlite
package which can be installed by running:
sudo apt-get install php5-sqlite
answered Mar 28, 2017 at 13:43
4