converting database from mysql to mongoDb

后端 未结 13 1321
陌清茗
陌清茗 2020-12-07 10:43

is there any easy way to change the database from mysql to mongoDB ?

or better any one suggest me good tutorial do it

13条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 11:02

    If anyone's still looking for a solution, i found that the easiest way is to write a PHP script to connect to your SQL DB, retrieve the information you want using the usual Select statement, transform the information into JSON using the PHP JSON Encode functions and simply output your results to file or directly to MongoDB. It's actually pretty simple and straight forward, the only thing to do is to double check your output against a Json validator, you may have to use functions such as explode to replace certain characters and symbols to make it valid. I have done this before however i currently do not have the script at hand but from what i can remember it was literally half a page of code.

    Oh also remember Mongo is a document store so some data mapping is required to get it to be acceptable with mongo.

提交回复
热议问题