Error: DB Error: [Error message: extension mysql is not compiled into PHP]

Practice



So, you have a web application. While it's running, the application writes an error like this to the logs:

DB Error: [Error message: extension mysql is not compiled into PHP]

And sometimes this looks strange, because both PHP and MySQL are installed, and normal PHP applications work with MySQL without any problems (the mysql_connect() function, for example, works fine, everything runs smoothly). But this particular application wants something else.


Solution

The thing is, this particular application works with MySQL through an extra layer - MDB2. And this package also has extensions, one of which is used for working with the MySQL server. That is, yes, PHP+MySQL normally work fine, but the application's developers decided to use another abstraction layer, which isn't immediately obvious (and oddly enough, it isn't always pulled in as a dependency). A clear example is Roundcube, which comes to us with exactly this problem: it doesn't pull in the required package as a dependency, but works specifically through MDB2.

So, we're missing the php-mdb2-driver-mysql package, and installing it will solve our problem.

For example, for Debian:
$ sudo apt-get install php-mdb2-driver-mysql

Or for CentOS/RHEL:
$ sudo yum install php-pear-MDB2-Driver-mysql.noarch


After installation, restart the Apache server.

For example, for Debian:
$ sudo /etc/init.d/apache2 restart

Or for CentOS/RHEL:
$ sudo /etc/init.d/httpd restart

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)