Ubuntu: mongodb driver not found


I am making a mongodb connection but when I access my config.php it give me the error

"mongodb driver not found".


try { $connectionString = "mongodb://" . $m4-live-mongodb;   $options = array( 'username' => 'hello', 'password' => 'world' );   // adding support for php 5.4 and uppper   if (($mv = phpversion('mongo')) === false)       {       throw new Exception("Mongo db driver not found");      }         elseif (version_compare($mv, '1.3.0', '<'))           {               $mongo = new Mongo($connectionString, $options);           } else           {           $mongo = new MongoClient($connectionString, $options);           } $mC = $mongo->$db->$collection; var_dump($mC);          } catch (exception $e)          {           echo $e->getcode().'<hr>'; echo $e->getmessage();           }   


The command pecl list lists the installed packages in the default channel. In the below code block the default channel is pecl.php.net

The command pecl search mongodb searches for the latest stable version of mongodb. Results of pecl search mongodb :

pecl search mongodb  Retrieving data...0%  Matched packages, channel pecl.php.net:  =======================================  Package Stable/(Latest) Local  mongodb 1.3.4 (stable)        MongoDB driver for PHP

When you are checking for mongodb version 1.3.0 you are getting the message Mongo db driver not found because the latest stable version of mongodb is not 1.3.0, it is 1.3.4. Check if the version of mongodb that you have installed is 1.3.4, and if so change your code accordingly.

According to your comment, you are using mongodb, not mongo. In line 4 of your PHP code change phpversion('mongo') to phpversion('mongodb').

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »