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,5725 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
8991 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,5725 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,5725 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,95118 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,2394 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
4794 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.8k21 gold badges141 silver badges227 bronze badges
@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
-
Максим
- Сообщения: 5992
- Зарегистрирован: 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
-
Максим
- Сообщения: 5992
- Зарегистрирован: 11 дек 2010, 20:29
Re: Ошибка Uncaught exception ‘PDOException’ with message ‘could not find driver’
Непрочитанное сообщение
Максим » 07 сен 2021, 18:47
voron121, вы ничего не можете понять, т.к. не читали или невнимательно прочитали руководство пользователя. В противном случае вы могли бы знать, что корректная среда окружения доступна только в тех программах, что запускаются из меню Open Server. А когда вы запускаете свои обычные программы в Windows они естественно не видят переменные окружения Open Server и вы получаете то, что получаете.
На будущее, предвидя ваше следующее непонимание, замечу, что если вы меняете версию любого модуля в настройках, то меняется и окружение. Поэтому программы, запущенные из меню ранее, необходимо перезапускать, чтобы они увидели обновлённое окружение. Всё это указано в руководстве.
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.
Contents
- 1 How to Fix Laravel PDOException could not find driver Error?
- 1.1 Solution 1 : Find php.ini path via phpinfo()
- 1.2 Solution 2 : Run the command
- 2 Conclusion
- 2.1 Also Read This Solutions
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
Привет
Пытаюсь выполнить данную команду из корня проекта zf2:vendorbindoctrine-module orm:validate-schema
Результат работы команды:
[Mapping] OK - The mapping files are correct.
[PDOException]
could not find driver
orm:validate-schema
Юзал поиск, но толкового ничего не нашел.
Были такие варианты, как проблемы с конфиг файлом. Вот мой конфиг:
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'DoctrineDBALDriverPDOMySqlDriver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'ZF2_Test',
)
)
),
),
);
Все путем + есть другой модуль, который работает с ORM Doctrine и он работает без каких-либо проблем.
Были варианты с неподключенным расширением extension=php_pdo_mysql.dll
в php.ini файле. Он у меня подключен в Php.ini + phpinfo() показывает, что PDO включено.
В итоге так и не нашел решения данной проблемы. Что может вызывать эту ошибку и как ее решать?
Спасибо
Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Laravel PDOException could not find driver in laravel. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
Contents
- How Laravel PDOException could not find driver Error Occurs ?
- How To Solve Laravel PDOException could not find driver Error ?
- Solution 1: missing dependency
- Solution 2: Edit your php.ini
- Solution 3: Run sudo apt-get install php7.0-mysql
- Solution 4: Install database first
- Summary
How Laravel PDOException could not find driver Error Occurs ?
I have Connected my MySQL database with Laravel and now I am facing the following error.
php artisan migrate:refresh --seed
[IlluminateDatabaseQueryException]
could not find driver (SQL: select * from usa_client where type = 'table ' and name = migrations)
[DoctrineDBALDriverPDOException]
could not find driver
[PDOException]
could not find driver
How To Solve Laravel PDOException could not find driver Error ?
- How To Solve Laravel PDOException could not find driver Error?
To Solve Laravel PDOException could not find driver Error Here you have a missing dependency If you can, run. composer update composer require doctrine/dbal second solution is First of all, run this command sudo apt-get update If you are using Mysql Database then run this command sudo apt-get install php-mysql and If you are using PostgreSQL Database then run this command sudo apt-get install php-pgsql Then run php artisan migrate
- Laravel PDOException could not find driver
To Solve Laravel PDOException could not find driver Error Here you have a missing dependency If you can, run. composer update composer require doctrine/dbal second solution is First of all, run this command sudo apt-get update If you are using Mysql Database then run this command sudo apt-get install php-mysql and If you are using PostgreSQL Database then run this command sudo apt-get install php-pgsql Then run php artisan migrate
Solution 1: missing dependency
Here you have a missing dependency If you can, run.
composer update
composer require doctrine/dbal
Solution 2: Edit your php.ini
Here you should install PDO on your server. And Edit your php.ini Find and uncomment the following line (remove the ;
character)
;extension=pdo_mysql.so //uncomment this line just remove ;
Then, restart your Apache server
Solution 3: Run sudo apt-get install php7.0-mysql
Running sudo apt-get install php7.0-mysql
fixed it for me.
Solution 4: Install database first
First of all, run this command
sudo apt-get update
If you are using Mysql Database
sudo apt-get install php-mysql
If you are using PostgreSQL Database
sudo apt-get install php-pgsql
Then
php artisan migrate
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- SyntaxError: invalid syntax to repo init in the AOSP code.
За последние 24 часа нас посетили 9575 программистов и 1222 робота. Сейчас ищут 398 программистов …
-
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
Всем привет, юзаю Laravel 6.8, Windows 7, OpenServer,PHP7.3, MySQL8, в php.ini все включено. ENV настроен правильно. При миграции( php artisan migrate) получаю:
Exception trace:
1 DoctrineDBALDriverPDOException:«could not find driver»)
D:ЗагрузкиWebOSPaneldomainsblogvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:31
php:312 PDOException:«could not find driver»)
D:ЗагрузкиWebOSPaneldomainsblogvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:27
php:27Переустановка OpenServer не помогла. Хелпп, несколько часов уже убил
-
lastdays
Активный пользователь- С нами с:
- 27 сен 2012
- Сообщения:
- 410
- Симпатии:
- 73
Не может найти драйвер.
По вопросам open server логично обращаться в тех. поддержку этого open-server, нет?
Когда то помогали по многим вопросам, если их правильно задать. -
Команда форума
Модератор- С нами с:
- 20 июн 2012
- Сообщения:
- 8.492
- Симпатии:
- 1.731
А pdo_mysql раскомментирован в php.ini?
-
это не к Laravel вопросы, это к Опенсерверу, он тебе драйвер нужный не установил
-
Алекс8
Активный пользователь- С нами с:
- 18 май 2017
- Сообщения:
- 1.730
- Симпатии:
- 359
если не сможешь мускул поднять то включи постгри.. тебе пофиг на самом то деле с чем ларка работать будет..
-
Алекс, твой ответ получает приз зрительских симпатий, однозначно
-
Команда форума
Модератор- С нами с:
- 11 июн 2010
- Сообщения:
- 10.825
- Симпатии:
- 1.174
- Адрес:
- там-сям
@konstantin501 в командной строке вызови
-
php -i | grep «PDO drivers»
и покажи нам результат, пожалуйста
konstantin501 нравится это.
-
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
С другими версиями Laravel все нормально
— Добавлено —Да, он расскоментирован
— Добавлено —У меня окна стоят
— Добавлено —
Даже не ожидал, что столько людей откликнется=) -
Алекс8
Активный пользователь- С нами с:
- 18 май 2017
- Сообщения:
- 1.730
- Симпатии:
- 359
сделай в веб директории проекта файл что то типа db.php
и из него сделай подключение к БД и проверь коннектится или нет.. -
Команда форума
Модератор- С нами с:
- 11 июн 2010
- Сообщения:
- 10.825
- Симпатии:
- 1.174
- Адрес:
- там-сям
и что с того, нет командной строки?
— Добавлено —
друг, раз ты решил вебдевом заняться, надо командную строку осваивать, полюбому. -
Алекс8
Активный пользователь- С нами с:
- 18 май 2017
- Сообщения:
- 1.730
- Симпатии:
- 359
а еще лучше отказываться от openserver и юзать докер…
я сам юзаю опенсервер и докер)) оперсервер лично для меня удобнее))
но я прекрасно понимаю что это от лени и нежелания настраивать докер)) -
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
Пишет, что grep — такой команды нету. Батюшка интернет говорит, что это терминальная команда на unix. Я знаю командную строку, но пока что не особо сильно
— Добавлено —Если так задуматься, то надо дофигище всего осваивать. Но на все это времени особо нету пока что, поэтому приходится тратить основное время языки и фреймворки, так как это основной инструмент
-
Алекс8
Активный пользователь- С нами с:
- 18 май 2017
- Сообщения:
- 1.730
- Симпатии:
- 359
да)) ты прав))
попробуй подключится к PDO без ларки)) -
Команда форума
Модератор- С нами с:
- 11 июн 2010
- Сообщения:
- 10.825
- Симпатии:
- 1.174
- Адрес:
- там-сям
grep есть везде. наверное надо добавить что-то, я сейчас не на винде, не могу конкретней сказать.
десятка вроде вообще в linux может. для семерки доступен cygwin, git shell, что-то-там в комплекте с vagrant (вроде gnuwin32), короче масса вариантов получить богатую командную строку. есть аналог от MS: findstr но я не знаю как им пользоваться.
— Добавлено —
я думаю что проблема в недоступности pdo_mysql, но надо это проверить. я указал как.другой способ: создать php файлик в папке public твоего проекта с таким содержимым:
и открыть его через браузер. там будет сводка какие расширения реально подключены.
-
То есть время на отлов глюков опенсервера есть, а на настройку нормальной среды исполнения — времени нет?
Нормальная логика
-
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
— Добавлено —
На настройку такого инструмента я потрачу больше времени) Особенно на винде, ибо на линуксе нет возможности сейчас учится)
— Добавлено —
я думаю что проблема в недоступности pdo_mysql, но надо это проверить. я указал как.другой способ: создать php файлик в папке public твоего проекта с таким содержимым:
и открыть его через браузер. там будет сводка какие расширения реально подключены.[/QUOTE]
Вложения:
-
Скрин.png
- Размер файла:
- 19,8 КБ
- Просмотров:
- 9
-
Алекс8
Активный пользователь- С нами с:
- 18 май 2017
- Сообщения:
- 1.730
- Симпатии:
- 359
-
Команда форума
Модератор- С нами с:
- 20 июн 2012
- Сообщения:
- 8.492
- Симпатии:
- 1.731
@konstantin501, не сходится. Там в опен сервере целый зоопарк версий php. У вас точно ларка под той же?
— Добавлено —
и .env покажите, без паролей, естественно -
Команда форума
Модератор- С нами с:
- 20 июн 2012
- Сообщения:
- 8.492
- Симпатии:
- 1.731
@konstantin50, вот я не пользуюсь Open Server, а и то знаю, что там много версий php…
-
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
на xampp поставил — тоже самое
-
- С нами с:
- 1 ноя 2016
- Сообщения:
- 1.523
- Симпатии:
- 345
@konstantin501, есть ведь ещё CLI со своим конфигурационным файлом.
Проверь настройки в ini-файле, путь до которого можно найти, выполнив в командной строке— Добавлено —
О чем, собственно, говорилось ещё и в #7
konstantin501 нравится это.
-
- С нами с:
- 17 дек 2019
- Сообщения:
- 11
- Симпатии:
- 0
Я забыл, что глобальная переменная у меня в другое место указана, заработало, спасибо)))) У меня была отдельная папка PHP , не помню зачем я вынес ее и указал путь к ней, и потом забыл поменять