Could not find pdo driver ... help :)

Hi there guys :slight_smile:

first post and first mess for me :rolleyes: !!
I recently got the italian version of “php mysql novice to ninja”, 5th edition by Kevin Yank… so far I just love the book.
I decided to go through the painful process of setting up everything needed in the manual way… I am kind new to linux, so I figured out that could be a good way to learn…
so I set up a linux mint vm on my win7 laptop. the vm works flawlessly, as far as I can see.
I installed mysql, php and apache according to the instructions found at the end of the book.
I can connect to apache server from the host without problems, I tried to execute some simple php script (input name and check, echo the date … simple things) and they run without problems.
I added a user to connect to mysql from the host (I know it is not really reccomended, but as I told you, it is all about learning) and from the host I can connect to mysql on the vm using mysql workbench.

I hit a wall, thought, when creating my first pdo object, since I get the funny “could not find driver” msg.
I searched both these forums and internet in general for some ideas, but of course the answers are kind of deeper than I can understand. Somewhere I read it is a good idea to echo the result of “phpinfo()”, and I did it. there is a section named “pdo”, a table whose headers is “pdo drivers”… and the table contains only 1 row, that is “sqlite”. funny thing, if I change the php code line I use to create the pdo object, and write sqlite instead of mysql, the error turns from “could not find driver” to “database not found”: of course, I did not set up the database under sqlite, but under mysql…

so guys, I can see the description I gave you of the situation is far from complete… but still, can any1 help or point me in the right direction? as I understand, I should “install mysql driver” for php… Did I get it right? and what is the procedure to install them? has any1 tried the manual installation of apache - mysql -php as explained in the book? can any1 give me any tip?
thanx for your attention :slight_smile: :slight_smile:

You may need to manually enable the PDO extension in the php.ini file; if you’re sure it’s installed try adding:

To your php.ini file.

Can you tell us the configure options you used when installing PHP? These should be available in the phpinfo script right at the top of the file.

ok as a first thanx for the reply :slight_smile:

I have a row entitled configure command, is that the one you are referring to??

Configure Command ‘./configure’ ‘–prefix=/usr/local/php’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–with-mysqli=/usr/local/mysql/bin/mysql_config’

and actually a “mysql_config” file is present under /usr/local/mysql/bin/

about the extension, that is somehow puzzling me. I found a section of php.ini with a bunch of “extension”, and I tried to “uncomment” the extension=php_mysql.dll, but nothing changed, and honestly I was expecting it: dll is related to windows :confused:
I tried to add the rows you wrote to me after all those “extension” but nothing really changed.

on the other hand I noticed there is a note before the extension section, it states that if I do not provide a path php is going to search for the extension in the default extension directory.
my phpinfo states
extension_dir /usr/local/php/lib/php/extensions/no-debug-zts-20121212
and if I surf that dir I just find a file.

is that the problem? do I have to point at another dir? should I copy the extension from somewhere?
if these are n00b questions please forgive me :slight_smile:

You need to reboot the server after making any changes to php.ini for the changes to take affect

I thought so :slight_smile: so I edited the changes before running the server…
I did something else :slight_smile:

if I launch from /usr/local
find . -iname “*.so” -follow
terminal gives me a number of files…
but if I type
find . -iname “” -follow
find . -iname “” -follow
I get nothing in return.

does that mean that I have both php and mysql but I am missing pdo driver for mysql?? =)

In your php.ini file does this line:


have a ; at the start of it? If it does, remove the ; from the start of that line, save, then reboot the server

did it, no go :confused:

but still, under phpinfo section “pdo” all I get is…

PDO support enabled
PDO drivers sqlite

Will it be a DLL file for a Linux install? Or should it be as below?

well, AFAIK dll are related to windows world, I never “met” a dll extension in linux. but I am kinda new around here, it might just be it a matter of time :slight_smile:

something more:
I found both a pdo and a mysqli dir
but they both contain 2 .h file each.
so more and more it seems like I did not install a required package. but the question is: wich one??

one step forward :wink: YEES :wink:
I added a foreach cycle at the start of the page (nothing special, just copied it from some page around)
for each (PDO::getAvailableDrivers() as $driver)
echo “<p>driver:”. $driver .“</p>”;

and of course, the only line I got was driver: sqlite

then I checked on mysql site

they say mysql driver is natively included into php starting from version 5.5

so I stopped apache,
got into the dir where I had downloaded php

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd
make install

then I restarted apache… and YES :slight_smile:

the page now lists

driver: mysql

and the error is no more “could not find driver”
“Access denied for user” …

which is still a bit weird, but it seems like a step forward :smiley: !!

now guys, a couple of questions:
1 is the book to be corrected? should I try to get in touch with mr. Kevin Yank and relate to him my experience?
2 what exactly did I do? why did I have to use the native driver instead of the mysql config??