Hello,

I am trying to install Drupal 7 locally, and it faiuls when I try to provide MySQL data:

- the ditribution is unpacked, sites/default is made writable by Web server, sites/default/files is created and made writable by Web server
- the http://example.com is loaded and installation starts

On step 3, when I copy sites/default/default.settings.php to sites/default/settings.php (Drupal doesn't do that, even though the directory is Web server writable), I am only offered SQLite engine choice.

When I manually add MySQL data, the installation fails with PHP fatal error. The trace is in the end of posting.

So, in short, is it really possible to install Drupal 7 on MySQL database? How it is done?

[06-Jan-2011 08:02:50] PHP Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /local/www/example.com/includes/database/mysql/database.inc on line 43
[06-Jan-2011 08:02:50] PHP Stack trace:
[06-Jan-2011 08:02:50] PHP 1. {main}() /local/www/example.com/install.php:0
[06-Jan-2011 08:02:50] PHP 2. install_drupal($settings = *uninitialized*) /local/www/example.com/install.php:27
[06-Jan-2011 08:02:50] PHP 3. install_run_tasks($install_state = array ('interactive' => TRUE, 'active_task' => 'install_verify_requirements', 'completed_task' => NULL, 'database_tables_exist' => FALSE, 'forms' => array (), 'installation_finished' => FALSE, 'locales' => array (0 => class stdClass { public $name = 'en'; public $langcode = 'en' }, './profiles/standard/translations/drupal-7.0-rc2.ru.po' => class stdClass { public $uri = './profiles/standard/translations/drupal-7.0-rc2.ru.po'; public $filename = 'drupal-7.0-rc2.ru.po'; public $name = 'drupal-7.0-rc2.ru'; public $langcode = 'ru' }), 'parameters' => array ('profile' => 'standard', 'locale' => 'en'), 'parameters_changed' => FALSE, 'profile_info' => array ('name' => 'Standard', 'description' => 'Install with commonly used features pre-configured.', 'version' => '7.0', 'core' => '7.x', 'dependencies' => array (0 => 'user', 1 => 'filter', 2 => 'node', 3 => 'system', 4 => 'field_sql_storage', 5 => 'text', 6 => 'field', 7 => 'block', 8 => 'color', 9 => 'comment', 10 => 'contextual', 11 => 'dashboard', 12 => 'help', 13 => 'image', 14 => 'list', 15 => 'menu', 16 => 'number', 17 => 'options', 18 => 'path', 19 => 'taxonomy', 20 => 'dblog', 21 => 'search', 22 => 'shortcut', 23 => 'toolbar', 24 => 'overlay', 25 => 'field_ui', 26 => 'file', 27 => 'rdf'), 'files' => array (0 => 'standard.profile'), 'project' => 'drupal', 'datestamp' => '1294208756', 'distribution_name' => 'Drupal', 'hidden' => FALSE, 'php' => '5.2.4'), 'profiles' => array ('standard' => class stdClass { public $uri = './profiles/standard/standard.profile'; public $filename = 'standard.profile'; public $name = 'standard' }, 'minimal' => class stdClass { public $uri = './profiles/minimal/minimal.profile'; public $filename = 'minimal.profile'; public $name = 'minimal' }, 'testing' => class stdClass { public $uri = './profiles/testing/testing.profile'; public $filename = 'testing.profile'; public $name = 'testing' }), 'server' => array (), 'settings_verified' => FALSE, 'stop_page_request' => FALSE, 'task_not_complete' => FALSE, 'tasks_performed' => array (0 => 'install_select_profile', 1 => 'install_select_locale', 2 => 'install_load_profile'))) /local/www/example.com/includes/install.core.inc:80
[06-Jan-2011 08:02:50] PHP 4. install_run_task($task = array ('display_name' => 'Verify requirements', 'display' => TRUE, 'type' => 'normal', 'run' => 3, 'function' => 'install_verify_requirements'), $install_state = array ('interactive' => TRUE, 'active_task' => 'install_verify_requirements', 'completed_task' => NULL, 'database_tables_exist' => FALSE, 'forms' => array (), 'installation_finished' => FALSE, 'locales' => array (0 => class stdClass { public $name = 'en'; public $langcode = 'en' }, './profiles/standard/translations/drupal-7.0-rc2.ru.po' => class stdClass { public $uri = './profiles/standard/translations/drupal-7.0-rc2.ru.po'; public $filename = 'drupal-7.0-rc2.ru.po'; public $name = 'drupal-7.0-rc2.ru'; public $langcode = 'ru' }), 'parameters' => array ('profile' => 'standard', 'locale' => 'en'), 'parameters_changed' => FALSE, 'profile_info' => array ('name' => 'Standard', 'description' => 'Install with commonly used features pre-configured.', 'version' => '7.0', 'core' => '7.x', 'dependencies' => array (0 => 'user', 1 => 'filter', 2 => 'node', 3 => 'system', 4 => 'field_sql_storage', 5 => 'text', 6 => 'field', 7 => 'block', 8 => 'color', 9 => 'comment', 10 => 'contextual', 11 => 'dashboard', 12 => 'help', 13 => 'image', 14 => 'list', 15 => 'menu', 16 => 'number', 17 => 'options', 18 => 'path', 19 => 'taxonomy', 20 => 'dblog', 21 => 'search', 22 => 'shortcut', 23 => 'toolbar', 24 => 'overlay', 25 => 'field_ui', 26 => 'file', 27 => 'rdf'), 'files' => array (0 => 'standard.profile'), 'project' => 'drupal', 'datestamp' => '1294208756', 'distribution_name' => 'Drupal', 'hidden' => FALSE, 'php' => '5.2.4'), 'profiles' => array ('standard' => class stdClass { public $uri = './profiles/standard/standard.profile'; public $filename = 'standard.profile'; public $name = 'standard' }, 'minimal' => class stdClass { public $uri = './profiles/minimal/minimal.profile'; public $filename = 'minimal.profile'; public $name = 'minimal' }, 'testing' => class stdClass { public $uri = './profiles/testing/testing.profile'; public $filename = 'testing.profile'; public $name = 'testing' }), 'server' => array (), 'settings_verified' => FALSE, 'stop_page_request' => FALSE, 'task_not_complete' => FALSE, 'tasks_performed' => array (0 => 'install_select_profile', 1 => 'install_select_locale', 2 => 'install_load_profile'))) /local/www/example.com/includes/install.core.inc:343
[06-Jan-2011 08:02:50] PHP 5. install_verify_requirements($install_state = array ('interactive' => TRUE, 'active_task' => 'install_verify_requirements', 'completed_task' => NULL, 'database_tables_exist' => FALSE, 'forms' => array (), 'installation_finished' => FALSE, 'locales' => array (0 => class stdClass { public $name = 'en'; public $langcode = 'en' }, './profiles/standard/translations/drupal-7.0-rc2.ru.po' => class stdClass { public $uri = './profiles/standard/translations/drupal-7.0-rc2.ru.po'; public $filename = 'drupal-7.0-rc2.ru.po'; public $name = 'drupal-7.0-rc2.ru'; public $langcode = 'ru' }), 'parameters' => array ('profile' => 'standard', 'locale' => 'en'), 'parameters_changed' => FALSE, 'profile_info' => array ('name' => 'Standard', 'description' => 'Install with commonly used features pre-configured.', 'version' => '7.0', 'core' => '7.x', 'dependencies' => array (0 => 'user', 1 => 'filter', 2 => 'node', 3 => 'system', 4 => 'field_sql_storage', 5 => 'text', 6 => 'field', 7 => 'block', 8 => 'color', 9 => 'comment', 10 => 'contextual', 11 => 'dashboard', 12 => 'help', 13 => 'image', 14 => 'list', 15 => 'menu', 16 => 'number', 17 => 'options', 18 => 'path', 19 => 'taxonomy', 20 => 'dblog', 21 => 'search', 22 => 'shortcut', 23 => 'toolbar', 24 => 'overlay', 25 => 'field_ui', 26 => 'file', 27 => 'rdf'), 'files' => array (0 => 'standard.profile'), 'project' => 'drupal', 'datestamp' => '1294208756', 'distribution_name' => 'Drupal', 'hidden' => FALSE, 'php' => '5.2.4'), 'profiles' => array ('standard' => class stdClass { public $uri = './profiles/standard/standard.profile'; public $filename = 'standard.profile'; public $name = 'standard' }, 'minimal' => class stdClass { public $uri = './profiles/minimal/minimal.profile'; public $filename = 'minimal.profile'; public $name = 'minimal' }, 'testing' => class stdClass { public $uri = './profiles/testing/testing.profile'; public $filename = 'testing.profile'; public $name = 'testing' }), 'server' => array (), 'settings_verified' => FALSE, 'stop_page_request' => FALSE, 'task_not_complete' => FALSE, 'tasks_performed' => array (0 => 'install_select_profile', 1 => 'install_select_locale', 2 => 'install_load_profile'))) /local/www/example.com/includes/install.core.inc:474
[06-Jan-2011 08:02:50] PHP 6. install_check_requirements($install_state = array ('interactive' => TRUE, 'active_task' => 'install_verify_requirements', 'completed_task' => NULL, 'database_tables_exist' => FALSE, 'forms' => array (), 'installation_finished' => FALSE, 'locales' => array (0 => class stdClass { public $name = 'en'; public $langcode = 'en' }, './profiles/standard/translations/drupal-7.0-rc2.ru.po' => class stdClass { public $uri = './profiles/standard/translations/drupal-7.0-rc2.ru.po'; public $filename = 'drupal-7.0-rc2.ru.po'; public $name = 'drupal-7.0-rc2.ru'; public $langcode = 'ru' }), 'parameters' => array ('profile' => 'standard', 'locale' => 'en'), 'parameters_changed' => FALSE, 'profile_info' => array ('name' => 'Standard', 'description' => 'Install with commonly used features pre-configured.', 'version' => '7.0', 'core' => '7.x', 'dependencies' => array (0 => 'user', 1 => 'filter', 2 => 'node', 3 => 'system', 4 => 'field_sql_storage', 5 => 'text', 6 => 'field', 7 => 'block', 8 => 'color', 9 => 'comment', 10 => 'contextual', 11 => 'dashboard', 12 => 'help', 13 => 'image', 14 => 'list', 15 => 'menu', 16 => 'number', 17 => 'options', 18 => 'path', 19 => 'taxonomy', 20 => 'dblog', 21 => 'search', 22 => 'shortcut', 23 => 'toolbar', 24 => 'overlay', 25 => 'field_ui', 26 => 'file', 27 => 'rdf'), 'files' => array (0 => 'standard.profile'), 'project' => 'drupal', 'datestamp' => '1294208756', 'distribution_name' => 'Drupal', 'hidden' => FALSE, 'php' => '5.2.4'), 'profiles' => array ('standard' => class stdClass { public $uri = './profiles/standard/standard.profile'; public $filename = 'standard.profile'; public $name = 'standard' }, 'minimal' => class stdClass { public $uri = './profiles/minimal/minimal.profile'; public $filename = 'minimal.profile'; public $name = 'minimal' }, 'testing' => class stdClass { public $uri = './profiles/testing/testing.profile'; public $filename = 'testing.profile'; public $name = 'testing' }), 'server' => array (), 'settings_verified' => FALSE, 'stop_page_request' => FALSE, 'task_not_complete' => FALSE, 'tasks_performed' => array (0 => 'install_select_profile', 1 => 'install_select_locale', 2 => 'install_load_profile'))) /local/www/example.com/includes/install.core.inc:719
[06-Jan-2011 08:02:50] PHP 7. drupal_check_profile($profile = 'standard') /local/www/example.com/includes/install.core.inc:1551
[06-Jan-2011 08:02:50] PHP 8. module_load_install($module = 'filter') /local/www/example.com/includes/install.inc:1129
[06-Jan-2011 08:02:50] PHP 9. module_load_include($type = 'install', $module = 'filter', $name = *uninitialized*) /local/www/example.com/includes/module.inc:262
[06-Jan-2011 08:02:50] PHP 10. drupal_get_path($type = 'module', $name = 'filter') /local/www/example.com/includes/module.inc:298
[06-Jan-2011 08:02:50] PHP 11. drupal_get_filename($type = 'module', $name = 'filter', $filename = *uninitialized*) /local/www/example.com/includes/common.inc:2664
[06-Jan-2011 08:02:50] PHP 12. db_query($query = 'SELECT filename FROM {system} WHERE name = :name AND type = :type', $args = array (':name' => 'filter', ':type' => 'module'), $options = *uninitialized*) /local/www/example.com/includes/bootstrap.inc:679
[06-Jan-2011 08:02:50] PHP 13. Database::getConnection($target = 'default', $key = *uninitialized*) /local/www/example.com/includes/database/database.inc:2218
[06-Jan-2011 08:02:50] PHP 14. Database::openConnection($key = 'default', $target = 'default') /local/www/example.com/includes/database/database.inc:1363
[06-Jan-2011 08:02:50] PHP 15. DatabaseConnection_mysql->__construct($connection_options = array ('driver' => 'mysql', 'database' => 'drupal7', 'username' => 'drupal', 'password' => 'myDrupal', 'host' => 'localhost', 'prefix' => array ('default' => ''))) /local/www/example.com/includes/database/database.inc:1573

Comments

KirstenLangholz’s picture

Hello,

I ran into the same poblem when I moved my D7 installation from XAMPP local installation to the 'Server2go' stick installation. I imported the database without any errors, but cannot open website afterwards. All rights set correctly.

Anybody with an idea where to turn to in order to solve the problem?

Thanks,
Kirsten

podarok’s picture

for me fix was installation php5-pdo_mysql (FreeBSD)
portinstall php5-pdo_mysql

---------------
Andrii Podanenko
CEO, ITCare

sinkarna’s picture

I have the same issue right now but I don't understand what's the fix?

Konstantin Boyandin’s picture

I suppose PDO_mysql module was missing.

DrupalUser78’s picture

Exactly that was it for Server2go!

After enabling the line (=removing the leading ; semicolon)
extension=php_pdo_mysql.dll
in the file \server\config_tpl\php.ini this error was gone.

Don't forget to reboot/restart your (Server2go-) server.

Thank you for this hint!

balakumarjayapal’s picture

it worked after enabling in php setting thanks

cmak’s picture

Thank you, enabling the php pdo extension solved the issue.

Senior Drupal Developer
Skype me on : mak_chavan
Email : Makarand Chavan

xamox’s picture

I had to install the php5-mysql binding on Ubuntu linux with:
sudo apt-get install php5-mysql

chirale’s picture

  • yum search php-mysql
  • yum install php-mysql.x86_64 (or similar)
aliaric’s picture

Got same problem at nginx + php-fpm
Seems I reinstalled php5-mysql extention and restarted php5-fpm.

adityamenon’s picture

Ubuntu's php5-mysql package probably installed the PDO driver for me. I just forgot to $ sudo service apache2 restart. It worked after that.

usman_ahmed’s picture

if you are on liver server please create a php.ini file on root directory and add this in it
[PHP]
extension=pdo.so
extension=pdo_mysql.so
and save your file.
done

if you are on local host please open you php.ini file and add this code in it.

Kimberley_p’s picture

Thanks very much after going round in circles a bit this simple fix worked for me.

monymirza’s picture

Quick and smart solution. Excellent.

Acquia Certified Developer - Drupal

mvsagar’s picture

Even though I had "extension=php_pdo_mysql.dll" in php.ini file and extension directory had the dll, the problem got fixed only after placing php.ini in C:\Windows directory.

Tommy_001’s picture

I had the same problem on a wamp environment and for me the solution was to simply go to Wamp->Apache->Version and click on the version number. Wait for 5 seconds or so until Apache is restarted. Done!

stuarteske’s picture

Thanks for that, worked for me.

bovidiu’s picture

I've hit this issue after installing memcache and trying to clear cache with drush.

To fix it, it wasn't need it to edit php.ini as much as it was missing php7.0-mysql . After installing it, i was able to run drush again (OS: Ubuntu 16)

shridhars’s picture

after installing php7.0-mysql Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' issue resolved

michaljenicek’s picture

thanks a lot, this solved my problem (I was upgrading from ubuntu 14.04 to 16.04)

dorficus’s picture

I checked my CLI php.ini and everything was enabled, however for some reason the CLI version of PHP was 7.1 but the mysql enabled was for 7.0. I ran sudo apt-get install php7.1-mysql and drush started working again.

arunkumark’s picture

Hi,
Am also facing the same problem on upgrading PHP version for my website from PHP 5 to PHP 7. In default, the pdo_mysql module does not exist. We need to manually download and install to our server. After enabling pdo_mysql module it working properly.
Command for enable pdo_mysql in PHP 7

sudo apt-get install php7.0-mysql
sudo phpenmod pdo_mysql
sudo service apache2 restart
sudishth’s picture

thanks @arunkumark

it working for me

annier77’s picture

Hello there, I don't know if anyone still responds to these threads but I'm quite desperate.

I'm very much a newbie to Drupal and took over 'managing' our website around 6 months ago; all I ever do is update Drupal core when necessary. In January, I had a lot of trouble installing a new module because the PHP installation was incorrect, so I messed around a bit with it then, but still couldn't figure out the issue. However, the website was fine until a couple of weeks ago, when someone notified me that the webpage was now showing "Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in .......[website name]....includes/database/mysql/database.inc on line 56". 

Thereafter I came to this thread. As I mentioned before, I'm working over SSH via the command line on quite the unfamiliar system, so any help would be greatly appreciated.

I've already re-installed the newest Drupal version via Cyberduck by using "rm -rf *.txt *.php includes/ misc/ modules/ profiles/ scripts/ *.config" and then "cp -R ~/drupal-7.59/* ."

When I run "uname -a" I get "Linux box501.bluehost.com 3.10.0-693.11.6.1.ELK.el6.x86_64 #1 SMP Tue Jan 23 10:30:30 MST 2018 x86_64 x86_64 x86_64 GNU/Linux". 

When I run "php -v" I get "

Copyright (c) 1997-2016 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.1.2, Copyright (c) 2002-2016, by ionCube Ltd.

    with SourceGuardian v11.1.0, Copyright (c) 2000-2017, by SourceGuardian Ltd.

    with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies"

When I run "sudo" anything, I get "sudo: effective uid is not 0, is sudo installed setuid root?".

And when I run "yum -v" I get "CRITICAL:yum.cli:Config Error: Error accessing file for config file:///etc/yum.conf".

This last error worries me too as I was thinking I could maybe solve these PHP (?) issues using yum to install, as apt-get doesn't work. Since "sudo" doesn't work either, I'm quite at a loss, as I'm a novice with system administration. Again, any help would be great.

AlbionBrown’s picture

I have the same error using Drupal 7.59 and PHP 7.1. In the PHP status report, it says I have the pdo_mysql and php7.1-mysql packages installed.

designcrs’s picture

I had the same problem on Windows - running Drupal 8 on IIS. Checking the output of phpinfo() made clear that the PDO module was not loaded. The fix was to change the "extension_dir" setting in php.ini to an absolute path. In my case this was

extension_dir = "C:\php\ext"

gandel’s picture

I use Dev desktop on windows you have to correct the path from

extension_dir = "C:\Program Files (x86)\DevDesktop\php7_1_x64\ext" to

extension_dir = "C:\Program Files (x86)\DevDesktop\php7_2_x64\ext"