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

Sign up to request clarification or add additional context in comments.

2 Comments

php5-gd I was missing =) after installing all the extensions, this was for me the solution, thanks!
This worked, I just needed to adjust the version sudo apt-get install php5.6-gd php5.6-mysql
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 Comments

yes That helped But What I just changed these two things database_host="127.0.0.1" database_port="3306" and it worked
I also Installed mysql on my ubuntu matchine apart from xampp
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 Comments

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.
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
@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.
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 Comments

jesus christ, thanks finally for that! I was looking half the internet for this answer that was finally correct for windows system....
Something similar worked for me on Windows, I uncommented ;extension=pdo_mysql
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.

Comments

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 Comment

In my case, I resolve it in this way: php7.0 app/console doctrine:schema:update --force
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.

Comments

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 

Comments

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.

Comments

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.

Comments

-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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.