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
Not enough user ratingsTotal: 624 This week: 1All time: 5,063 This week: 560Up
Version License PHP version Categories
mysql-to-mongo 1.1GNU Lesser Genera...5.3PHP 5, Databases, Systems administration
Description 

Author

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
Winner


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: 411 Up18 in Italy Italy Up
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

Example

<?php

require_once("MySqlToMongo.php");

$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
$imp->setBatchRecords(1000);

//Set debug mode to read debug messages
$imp->setDebugMode(true);

//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
$imp->setDropIfExists(true);

//Starting import session
$imp->import($tables);


  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  
 0%
Total:624
This week:1
All time:5,063
This week:560Up
User Comments (1)
very good class
9 years ago (pooya sabramooz)
70%StarStarStarStar