I am trying to install Drupal 7 on PHP 5.2.16.
When I enter MySQL data to settings.php (otherwise I am only offered SQLite), the installation fails with this diagnostics:

PHP Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /local/www/example.com/includes/database/mysql/database.inc on line 43

I enclose both PHP trace file and the output of 'php -m'.

CommentFileSizeAuthor
php.txt355 bytesKonstantin Boyandin
trace.txt10.9 KBKonstantin Boyandin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Konstantin Boyandin’s picture

The PHP was configured this way:

./configure \
--prefix=/usr/local/php-5.2.16-cgi \
--with-libdir=lib64 \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-magic-quotes \
--with-mysqli=shared,/usr/bin/mysql_config \
--with-mysql=shared \
--with-openssl=shared \
--with-kerberos \
--with-pear \
--enable-sockets \
--with-zlib=shared \
--with-curl=shared \
--with-gd=shared \
--with-jpeg-dir=shared,/usr \
--enable-mbstring \
--with-iconv=shared \
--with-imap=shared \
--with-imap-ssl=shared \
--with-ldap=shared \
--with-ldap-sasl \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvsem \
--enable-sysvmsg \
--with-freetype-dir=/usr \
--with-mcrypt=shared \
--with-gettext=shared \
--enable-cgi \
--enable-fastcgi \
--enable-force-cgi-redirect

PHP is run as FastCGI. OS is Fedora 14 and Centos 5.5, in both cases Drupal 7 installation fails. The above configuration works perfectly with my production sites on Drupal 5 and Drupal 6 for years.

bfroehle’s picture

Hi Konstantin,

Is there any chance you have the PECL PDO installed instead of the default PHP PDO? See PDO Requirements for more information.

Thanks for the bug report.

Konstantin Boyandin’s picture

2bfroehle: Negative. I haven't installed the PECL PDO; the PDO support is enabled in PHP build by default.

Right now I try to figure out how to bypass this without reconfiguring PHP entirely (adding more modules is OK) and/or hacking into Drupal code myself.

Thanks.

Konstantin Boyandin’s picture

Looks like I've found the solution. If PHP is built manually, the following configure option does the trick:

--with-pdo-mysql=shared

('shared' is optional)

Of course, the line
extension=pdo_mysql.so
must be added in php.ini as well.

With this fix, the installation goes on well. I suggest adding this comment to the installation manual provided with Drupal 7 distibution.

univate’s picture

Category: bug » support
Priority: Critical » Normal

Its already mentioned in the PDO requirements linked above.

How to enable PDO

To enable PDO configure --enable-pdo and --with-pdo_sqlite --with_pdo_mysql or whatever database needs supporting by PDO.
cottlem’s picture

Could it be that the minimum requirements for Drupal 7 is PHP 5.3 & you are installing on 5.2.16?

Konstantin Boyandin’s picture

No, apart from PDO for MySQL, all requirements have been met.

OK, so the only suggestion remained is that in such a case Drupal won't die with a blank screen, but reported something like 'There is no required PDO module for the database you chose, please refer to for more information".When building PHP manually, only PDO for sqlite is built by default.

Thanks.

bfroehle’s picture

Since it seems that the db folks are always looking for more reliable detection mechanisms, perhaps we should add checking for this class constant to the list of requirements for MySQL?

Damien Tournoud’s picture

Title: Attempt to install on MySQL engine generates PHP fatal error Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' » The installation process triggers the loading of the database connection before it is checked
Category: support » bug

There is a real bug here: the database connection is loaded by drupal_get_filename() triggered by drupal_check_profile() even before the setting files is verified.

That means that if you define 'driver' => 'toto' in your settings.php, Drupal will die with Fatal error: require_once() [function.require]: Failed opening required 'includes/database/toto/database.inc' in includes/database/database.inc on line 1572. This is silly and should definitely never happen.

I suggest we do the requirement checks for settings first, and then move on to checking the profile.

steper’s picture

Do not forget to give to setting.php permission to 777 and change than to 755, has helped me!!!

charlie-s’s picture

I second #9. I got the error Failed opening required 'includes/database/mysqli/database.inc' and thought "certainly Drupal shouldn't be checking folders that don't exist".

RowboTony’s picture

I also got this error, and found this thread as one of the top Google results. Just a quick note about my situation - I was getting this error on a site that I upgraded from D6 to D7. Ultimately I discovered the problem was with the backup_migrate module. I don't know why backup migrate caused the issue, I just know it took me 3 hours to figure out the problem :( I assume backup_migrate had some setting somewhere left over from D6 that still called for the includes/database/mysqli/database.inc code when it was enabled. So I disabled backup_migrate and all is well, enable backup_migrate and the error happens. I'll leave backup_migrate off for now :)

-- Tony

Version: 7.0 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.