Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDOException could not find driver

Tags:

symfony

im working with symfony and when i type in console this:

php app/console doctrine:schema:create

i have the next errors

[Doctrine\DBAL\Exception\DriverException]

An exception occured in driver: could not find driver

[Doctrine\DBAL\Driver\PDOException]
could not find driver

[PDOException]
could not find driver

I've been following this link in order to sort it out

PDOException “could not find driver” in php

this is what i get when i run php -m

root@asus-K53SD:/opt/lampp/htdocs/symfonycurso# php -m
[PHP Modules]
calendar
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlr    eader
xmlwriter
xsl
Zend OPcache
zlib
Zend Modules
Zend OPcache

i uncommented this and restart the server

extension=php_pdo_pgsql.dll

this is my parameter.yml

Added database_driver : pdo_mysql and password removed (before was null)

 # This file is auto-generated during the composer install
parameters:
database_driver  : pdo_mysql
database_host: 127.0.0.1
database_port:
database_name: blog
database_user: root
database_password:
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user:
mailer_password:
secret: ThisTokenIsNotSoSecretChangeIt

anyone know how can i fix this errors?? can be the problem that im working on PHP7

NOTE: Using lampp on linux

like image 364
Zenit Avatar asked Apr 20 '17 22:04

Zenit


People also ask

How do I install PDO drivers?

Pdo ( Portable Data Object ) needs to be installed if it is not done before. For windows platform go to control panel > Add remove program ( or Programs and features ) > Select your PHP installation and click Change. If you are installing PHP fresh then in the setup wizard you can select PDO from Extensions link.

Could not find driver error php?

If you see "PDOException : could not find driver" in your error logs, that means the SQLite PDO driver is not installed on your server. The SQLite PDO driver is listed as a prerequisite in the help article " Verify your prerequisites".

What is Pdo_mysql?

PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL databases. PDO_MYSQL uses emulated prepares by default. MySQL 8. When running a PHP version before 7.1. 16, or PHP 7.2 before 7.2.


1 Answers

Using LAMP you don't need to enable php_pdo_mysql.dll in the .ini file. Instead, run this below command in cli,

sudo apt-get install php7.0-mysql (Use specific PHP version which you used).

Now you can see pdo_mysql module by running php -m command.

Then, you clear the cache in symfony and run the symfony commands.

like image 62
Aarief Mohideen Avatar answered Sep 18 '22 22:09

Aarief Mohideen