[newbie] import mysql to mongoDB

633 views
Skip to first unread message

zack_syah

unread,
Sep 27, 2011, 4:33:21 AM9/27/11
to mongod...@googlegroups.com
how to convert sql file to mongoDB file, i use Mysql before. My SQL file size is 200MB
please tell me step by step

This design my sql tables, what if in MongoDB? or i just import the ukm tables only?


I want to build search engine to this database with mongoDB
thanks b4

Sam Millman

unread,
Sep 27, 2011, 4:55:53 AM9/27/11
to mongod...@googlegroups.com
"This design my sql tables, what if in MongoDB? or i just import the ukm tables only?"

This massively depends on if you wish to have the exact same structure as MySQL which may not be NoSQL optimised or you are prepared to start from scratch and make a NoSQL optimised structure.

"I want to build search engine to this database with mongoDB"

You'd be better off with Sphinx/Xapian/Solr/Lucene/Zoie/SenseiDB for search techs.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/vK-3gOCumhoJ.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Flavio Percoco

unread,
Sep 27, 2011, 5:12:17 AM9/27/11
to mongod...@googlegroups.com
Plus, I'd suggest to read data directly from the database instead. This link[0] may be useful

And plus, ElasticSearch

[0] http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart

Fla





Sam Millman
27 de septiembre de 2011 10:55

"This design my sql tables, what if in MongoDB? or i just import the ukm tables only?"

This massively depends on if you wish to have the exact same structure as MySQL which may not be NoSQL optimised or you are prepared to start from scratch and make a NoSQL optimised structure.

"I want to build search engine to this database with mongoDB"

You'd be better off with Sphinx/Xapian/Solr/Lucene/Zoie/SenseiDB for search techs.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


zack_syah
27 de septiembre de 2011 10:33

Stanislav Pogrebnyak

unread,
Sep 27, 2011, 5:44:12 AM9/27/11
to mongod...@googlegroups.com
If you want to export/import huge amounts from MySQL to mongo u better use SELECT * INTO OUTFILE MySQL construction wich can prepare very clean tsv file for you. Those you can import in to mongo with mongoimport.

During that process mysql can be a bottle neck and exporting that way really speeding up the process.

zack_syah

unread,
Sep 27, 2011, 6:25:30 AM9/27/11
to mongod...@googlegroups.com
whether using MongoVUE | Gui tools for MongoDB can?
I was confused at my table design there is a relative, in MongoDB's no relation. So what do I import only tables ukm?

Stanislav Pogrebnyak

unread,
Sep 27, 2011, 10:13:38 AM9/27/11
to mongod...@googlegroups.com
I would suggest u to analyze MySQL db structure and transpose it to MongoDB, usually thats not just a import/export processes, but u can do a tricks like embedding relational data in to collection items, ability to do that is the biggest mongo's strength.
Maybe, We could say more about how to import/export if u show the MySQL schema. 
it can be done from mysql console with

> show tables;

and 

show create table $table_name;

or with some other tools GUI tools maybe


Sergei Tulentsev

unread,
Sep 27, 2011, 3:02:07 PM9/27/11
to mongod...@googlegroups.com
When I was migrating my 500+Gb database, I used complicated 'select into outfile' that was writing JSON. For some reason I preferred this approach over tsv/csv, but I don't really remember why :-)

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/6uzBF4MIq7YJ.

To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.



--
Best regards,
Sergei Tulentsev

Stanislav Pogrebnyak

unread,
Sep 27, 2011, 4:15:56 PM9/27/11
to mongod...@googlegroups.com
Probably because csv not working well, as well as multi lined tsv ;)

zack_syah

unread,
Sep 27, 2011, 7:18:37 PM9/27/11
to mongod...@googlegroups.com

this is my schema relation, so how do I change it to mongoDB structure? mongoDB database doesn't relate
please let me know step by step ;)

zack_syah

unread,
Sep 27, 2011, 7:20:54 PM9/27/11
to mongod...@googlegroups.com
to Mr Stanislav Pogrebnyak  so I have to convert it into a form tsv per table, and then import them directly to MongoDB or what?

sathis

unread,
Sep 27, 2011, 11:22:22 PM9/27/11
to mongodb-user


On Sep 28, 4:20 am, zack_syah <slash...@gmail.com> wrote:
> to Mr Stanislav Pogrebnyak  so I have to convert it into a form tsv per
> table, and then import them directly to MongoDB or what?

Zack,

I have written a utility to import Sql data to mongodb. See whether it
can help you in some way.
http://code.google.com/p/sql-to-mongo-importer/

Stanislav Pogrebnyak

unread,
Sep 28, 2011, 2:41:40 AM9/28/11
to mongod...@googlegroups.com
First of all you need to deside what schema u will have in mongo and what schema will suits you best due to your requirements. After that u can build appropriate export/import process.

Stanislav Pogrebnyak

unread,
Sep 28, 2011, 2:53:25 AM9/28/11
to mongod...@googlegroups.com
Ok, for migrating to mongo there are some tricks those can be used, like 1 : M relation converting to embedded array, like :

posts( id )
posts_categories( post_id, category_id )
categories( id, name )
coments( id, post_id, author, text )

becomes in MongoDB:

posts: [
   _id : {
      categories : [ "one", ... , ]
      comments : [
        { author : "", text : "" }
      ]
   },
   ...
]

the sample probably trite, but thats really illustrates the process. U need to decompose relations in to attributes or embedded layers like i'v showed with comments.

Its a bit hard to overview your schema since identifiers arent in english and hard to find out the purpose of the entities.


zack_syah

unread,
Oct 4, 2011, 11:10:11 AM10/4/11
to mongod...@googlegroups.com
ok this is my database change into english

I want to build search engine for this database, for example I want to find one of the province's name, business name and other.

zack_syah

unread,
Oct 5, 2011, 8:41:11 AM10/5/11
to mongod...@googlegroups.com
Can mongoVUE convert mysql file to mongoDB perfectly?

Sam Millman

unread,
Oct 5, 2011, 11:18:52 AM10/5/11
to mongod...@googlegroups.com
"I want to build search engine for this database, for example I want to find one of the province's name, business name and other."

This may sound ironic here but a search tech would do that better for you. I have said once before you should look into that.

As for converting the DB, MongoVUE might be able to convert that DB to a format, whether or not it is the format you are looking for is another question.

To be honest, with such a simple DB I would manually normalise the SQL structure into a NoSQL structure. Thing is MongoVUE could convert across the joins but that is not nessecarily what you want.

An example of manually designing the schema would be:

Merge ukm and desa so that desa is a sub document. Merge kbli into the ukm table too.

That would be an example of normalising it yourself, at the end of the day this is normally the best way. Trusting something that cannot understand the purpose of your DB to reconstruct your DB just sounds dangerous to me.

On 5 October 2011 13:41, zack_syah <slas...@gmail.com> wrote:
Can mongoVUE convert mysql file to mongoDB perfectly?

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/DCM7P8Ctnp8J.

Sam Millman

unread,
Oct 5, 2011, 11:24:25 AM10/5/11
to mongod...@googlegroups.com
Though coming back to all this:

"I want to build search engine for this database, for example I want to find one of the province's name, business name and other."

Is this the primary function of the DB? Is this a search site you are building?
Message has been deleted

zack_syah

unread,
Dec 24, 2011, 4:49:06 AM12/24/11
to mongod...@googlegroups.com
Yes the primary function of the DB is for search engine

Madhava

unread,
Dec 24, 2011, 12:13:53 PM12/24/11
to mongodb-user
Then your best bet as mentioned previously is to use - Solr / Lucene,
or any other search library.
Reply all
Reply to author
Forward
0 new messages