22

I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command

php app/console doctrine:schema:create

I am getting the following error message:-

PDOException “could not find driver”

I also uncomment this line extension=php_pdo_mysql.dll in php.ini file

I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----

Is there a way i can remove this issue ?

11 Answers 11

20

In Ubuntu, write in the console

sudo apt-get install php5-gd php5-mysql

and it will work

2
  • php5-gd I was missing =) after installing all the extensions, this was for me the solution, thanks! Commented May 9, 2017 at 18:49
  • 1
    This worked, I just needed to adjust the version sudo apt-get install php5.6-gd php5.6-mysql
    – Josafat
    Commented Feb 13, 2019 at 22:47
12

Hope you are running your project in localhost. In your project folder app/config a file named parameters.ini , Make sure that your Mysql database connection cofiguration is correct. If you are using mysql See database_driver=pdo_mysql is its driver.

Below is an example.

database_driver   = pdo_mysql
    database_host     = localhost
    database_port     =
    database_name     = databasename
    database_user     = msqlusername
    database_password = mysqlpassword//if not make blank

    mailer_transport  = smtp
    mailer_host       = localhost
    mailer_user       =
    mailer_password   =

    locale            = en

    secret            = ThisTokenIsNotSoSecretChangeIt

Hope it helps you.

2
  • yes That helped But What I just changed these two things database_host="127.0.0.1" database_port="3306" and it worked
    – ScoRpion
    Commented Feb 17, 2012 at 6:13
  • I also Installed mysql on my ubuntu matchine apart from xampp
    – ScoRpion
    Commented Feb 21, 2012 at 8:47
6

You need to have a module called pdo_mysql.

Look for the following in phpinfo() output,

pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44

to install pdo_mysql you need to do this:

 pecl install pdo
 pecl install pdo_mysql

and then add the following to your php.ini file:

extension=pdo.so
extension=pdo_mysql.so
3
  • ahh ok. I thought you are on linux. well bottom line is that you will need pdo_mysql module to get your PDO stuff working. I am not aware of lampp. it could be as simple as checking if the pdo_mysql dll file is present. Restart your Apache service after uncommenting pdo_mysql.dll package in your ini file. Commented Feb 16, 2012 at 9:11
  • I am using lampp. a package that installs php, appache and mysql its own way rather in default folders..and these cmds give me errors configure: error: Cannot find MySQL header files under ERROR: `/tmp/pear/temp/PDO_MYSQL/configure' failed
    – ScoRpion
    Commented Feb 16, 2012 at 9:13
  • @Jaspreet Chahal, is your answer works on Linux? I have the same problem with OP but I don't have permission to edit the php.ini file. If your answer really works, I will ask permission to my supervisor to include it in php.ini file. Commented Mar 8, 2018 at 1:33
2

if you are using XAMPP then in php.ini file line no 897(depends on version),

;extension=php_pdo_pgsql.dll 

uncomment it , then it appears like below

extension=php_pdo_pgsql.dll 

in php.ini file line no 897, then restart XAMPP.

2
  • 1
    jesus christ, thanks finally for that! I was looking half the internet for this answer that was finally correct for windows system....
    – MarcL
    Commented Dec 7, 2020 at 15:10
  • Something similar worked for me on Windows, I uncommented ;extension=pdo_mysql
    – Amon
    Commented Oct 16, 2023 at 2:02
1

brew install php70-pdo-pgsql in case you installed php7 on mac with brew and, change php version according to what you have installed.

0
1

There are two PHP versions installed in my server PHP 5.6 and PHP 7

When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver

I resolve this error by specifying the PHP version:

php5.6 app/console doctrine:schema:update
1
  • 1
    In my case, I resolve it in this way: php7.0 app/console doctrine:schema:update --force
    – Lisandro
    Commented Jan 24, 2019 at 19:46
1

Adding to Jaspreet Chahal's answer.
When installing PDO as a shared module, the php.ini file needs to be updated so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step(Source).

What I mean is, it should look something like this -

extension=pdo.so should be placed before the extensions of the different database drivers.

1

Maybe you forget to install doctrine/dbal

composer update

composer require doctrine/dbal

if it didn't work go to your php.ini (according to current version) and remove ";"

;extension=pdo_mysql.so
0

Looks like your install is missing the .so files it needs to implement the mysql connection. If you're using a package management system to install PHP then make sure you've installed all the necessary submodules (in this case I think you'll need mysql-dev, and the various PHP PDO modules), though such dependencies should have been resolved for you by the package manager.

If you didn't go through a package manager, then you'll have to compile the required .so files from source.

0
0

I had the same problem and for me, it was having multiple PHP versions. So specifying the full address of the PHP solved the problem.

-1

For anyone here in the future:

On Windows 10 I had to uncomment ;extension=pdo_mysql then restart the server for it to work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.