PHP Classes

PHP MySQL to Mongo: Import MySQL database into MongoDB

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 624 All time: 5,064 This week: 455Up
Version License PHP version Categories
mysql-to-mongo 1.1GNU Lesser Genera...5.3PHP 5, Databases, Systems administration


This class can import MySQL database into MongoDB.

It can connect to a given MySQL server to retrieve the records of the tables.

The class can recreate the table records and indexes in a given MongoDB.

Innovation Award
PHP Programming Innovation award winner
August 2014

Prize: PhpStorm IDE personal permanent license
The possibilities of NoSQL databases motivated many developers to switch from traditional SQL databases like MongoDB.

This class provides an useful solution for those that want to migrate their MySQL databases to MongoDB.

Manuel Lemos
Picture of Orazio Principe
  Performance   Level  
Name: Orazio Principe is available for providing paid consulting. Contact Orazio Principe .
Classes: 8 packages by
Country: Italy Italy
Age: 47
All time rank: 64123 in Italy Italy
Week rank: 307 Up10 in Italy Italy Up
Innovation award
Innovation award
Nominee: 4x

Winner: 2x




$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pswd = "";
$mysql_database = "test";

$mongo_host = "localhost";
$mongo_user = "";
$mongo_pswd = "";
$mongo_database = "test";

$imp = new MySqlToMongo();

//Establishing connections to mysql and mongo instances
$imp->mysql_connect($mysql_host, $mysql_user, $mysql_pswd, $mysql_database);
$imp->mongodb_connect($mongo_host, $mongo_user, $mongo_pswd, $mongo_database);

//Set the number of concurrent records to insert

//Set debug mode to read debug messages

//Get all tables from the database
//if you want to import single tables just pass an array of names ex: $list("tbl1","tbl2")
$tables = $imp->getMySqlTables();

//Set the dropping tables if exists into mongo. If false it will append records

//Starting import session

  Files folder image Files  
File Role Description
Plain text file MySqlToMongo.php Class Main Class
Accessible without login Plain text file MySqlToMongo_test.php Example Example file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:5,064
This week:455Up
User Ratings User Comments (1)
 All time
very good class
9 years ago (pooya sabramooz)