I got an email today – a FreeBSD 8.2 Web server installation with Apache and PHP 5.3 was missing its mySQL driver. No it wasn’t, I protested. But this error was appearing:
[error] [exception.CDbException] could not find driver
[error] [exception.CDbException] exception 'CDbException' with message 'CDbConnection failed to open the DB
“It’s not the database, it’s the PDO module”, came the explanation. Actually the pdo.so module was there and loaded, and it was installed in just the same way as it had been on earlier versions. So what was going on?
It turns out that as of PHP 5.3 there has been a change. You don’t get the important module – pdo_mysql – loaded when you compile /usr/ports/lang/php5-extensions. It’s not that it’s no longer checked by default – it’s not even there! I’m told this applies to Postgress too.
Further investigation revealed that PHP5.3 has a new native-mode driver (mysqlnd), and this is now outside the standard install. If you’re using sqlite for Persistant Data Objects, no problem, but if you’re using a more restrictive hosting account and therefore need to store them in a mySQL (or Postgress) database you seem to be out of luck.
For more information, see here.
However, the required module can still be found. Go to
/usr/ports/databases/php5-pdo_mysql
(If you’re using Postgress go to php5-pdo_pgsql instead – see Geoffrey McRae’s comment below).
make and make install what you find there. Also, make sure you compiled the original php5-extensions with mysql and mysqli, and don’t forget to restart Apache afterwards!
Note that it’s quite possible that none of the above relates to Linux. It’s to do with what gets installed from where with the FreeBSD ports tree.
Thanks for the writeup, but you have a mistake in the information that is actually what I was looking for…
Your article is all about MySQL, but then you tell people to install the PDO driver for PostgreSQL (which is actually what I needed).
You’re right! I tend to write these things up late at night after I’ve already burnt myself out fixing the problem and somehow I must have cut/pasted the wrong driver name into the post. I’ve just been back to the server in question to check, and I had only actually compiled the mysql version.
From what you’re saying, I assume this feature exists with Postgress too, and I’d guess sqlite and db2 as well. If you can tell me its the same I’ll go through and update it for both.
Thanks for taking the trouble to let me (and other’s Googling for the same problem) know.
(For the curious, I’d typed pdo_pgsql instead of pdo_mysql – now fixed)