1
votes

I have a problem with magento command : php shell/indexer.php reindexall

Stack trace:

0 /home/taatoo/www/lib/Zend/Db/Adapter/Abstract.php(459): > Varien_Db_Adapter_Pdo_Mysql->_connect()

1 /home/taatoo/www/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)

2 /home/taatoo/www/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)

3 /home/taatoo/www/app/code/core/Mage/Core/Model/Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')

4 /home/taatoo/www/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))

5 /home/taatoo/www/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write')

6 /home/taatoo/www/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(350): Mage_Core in /home/taatoo/www/lib/Varien/Db/Adapter/Pdo/Mysql.php on line 302

Lines 301/302/303 are :

if (!extension_loaded('pdo_mysql')) {
    throw new Zend_Db_Adapter_Exception('pdo_mysql extension is not installed');
}

Or, if I execute print_r(get_loaded_extensions()); in /home/project/www/ or /home/project/www/lib/Varien/Db/Adapter/Pdo/ I correctly get the "pdo_mysql" extension.

I also get true if I do var_dump(extension_loaded('pdo_mysql')); in this script.

But false if I do the same things in /home/project/www/lib/Varien/Db/Adapter/Pdo/Mysql.php

2
Are you doing that print_r/var_dump in your browser? It sounds like his is a mismatch between web and console PHP configuration :)Daniel Sloof
Yep @DanielSloof it seems so for me too ;)Cyril N.

2 Answers

1
votes

As mentioned in the comments you might be using two different php.ini files.
To check that please change the throw new Zend_Db_Adapter_Exception line to

throw new Zend_Db_Adapter_Exception(
  'pdo_mysql extension is not installed. php.ini:'
  . get_cfg_var('cfg_file_path')
);

and compare the result with the output of

var_dump(get_cfg_var('cfg_file_path'), extension_loaded('pdo_mysql'));

in your command line script.

see also:
http://docs.php.net/manual/en/function.get-cfg-var.php
http://docs.php.net/manual/en/function.php-ini-loaded-file.php
http://docs.php.net/manual/en/function.php-ini-scanned-files.php

1
votes

You often find that PHP for the web and PHP CLI (Command Line Interface) use different php.ini files. Since your problem is happening in CLI, type php -m and see if pdo_mysql is in the list. If it isn't you can find out which php.ini file to edit by typing php --ini.

The line that needs to be in php.ini is extension=php_pdo_mysql.so. Most likely it's there, but commented out with a semicolon.