本文目錄一覽:
如何從MongoDB遷移到MySQL
如何將MongoDB資料庫的數據遷移到MySQL資料庫中
先把oracle的數據導出為平面文件,比如txt或csv 然後再導入進mongodb就好了! oracle數據導出的話,可以試試用sqluldr
如何將MongoDB資料庫的數據遷移到MySQL資料庫中
如何將MongoDB資料庫的數據遷移到MySQL資料庫中
先把oracle的數據導出為平面文件,比如txt或csv 然後再導入進mongodb就好了! oracle數據導出的話,可以試試用sqluldr
教你如何利用MySQL學習MongoDB之導入和導出
1、MySQL導入和導出(1)、mysqlimport此工具位於mysql/bin目錄中,是MySQL的一個載入(或者說導入)數據的一個非常有效的工具。這是一個命令行工具。有兩個參數以及大量的選項可供選擇。這個工具把一個文本文件(text file)導入到你指定的資料庫和表中。比方說我們要從文件student.txt中把數據導入到資料庫class中的表 student中:mysqlimport class.student student.txt(2)、load data infile這個命令與mysqlimport非常相似,但這個方法可以在MySQL命令行中使用。 如mysqlimport工具一樣,這個命令也有一些可以選擇的參數。比如您需要把自己的電腦上的數據導入到遠程的資料庫伺服器中,您可以使用下面的命令:Load data local infile “d:\student.txt” into table student;上面的local參數表示文件是本地的文件,伺服器是您所登陸的伺服器。這樣就省去了使用ftp來上傳文件到伺服器,mysql替你完成了。(3)、mysqldumpmysqldump工具很多方面類似相反作用的工具mysqlimport。它們有一些同樣的選項。但mysqldump能夠做更多的事情。它可以把整個資料庫裝載到一個單獨的文本文件中。這個文件包含有所有重建您的資料庫所需要的SQL命令。這個命令取得所有的模式並且將其轉換成DDL語法,取得所有的數據,並且從這些數據中創建INSERT語句。這個工具將您的資料庫中所有的設計倒轉。因為所有的東西都被包含到了一個文本文件中。這個文本文件可以用一個簡單的批處理和一個合適SQL語句導回到MySQL中。這個工具令人難以置信地簡單而快速。決不會有半點讓人頭疼地地方。因此,如果您像裝載整個資料庫mydb的內容到一個文件中,可以使用下面的命令:bin/mysqldump –p mydb mydb.txt2、MongoDB導入和導出(1)、mongoexport導出工具MongoDB提供了mongoexport工具,可以把一個collection導出成json格式或csv格式的文件。可以指定導出哪些數據項,也可以根據給定的條件導出數據。工具幫助信息如下:[root@localhost bin]# ./mongoexport –help options: –help produce help message -v [ –verbose ] be more verbose (include multiple times for more verbosity e.g. -vvvvv) -h [ –host ] arg mongo host to connect to ( /s1,s2 for sets) –port arg server port. Can also use –host hostname:port –ipv6 enable IPv6 support (disabled by default) -u [ –username ] arg username -p [ –password ] arg password –dbpath arg directly access mongod database files in the given path, instead of connecting to a mongod server – needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path –directoryperdb if dbpath specified, each db is in a separate directory -d [ –db ] arg database to use -c [ –collection ] arg collection to use (some commands) -f [ –fields ] arg comma separated list of field names e.g. -f name,age –fieldFile arg file with fields names – 1 per line -q [ –query ] arg query filter, as a JSON string –csv export to csv instead of json -o [ –out ] arg output file; if not specified, stdout is used –jsonArray output to a json array rather than one object per line [root@localhost bin]# 下面我們將以一個實際的例子說明,此工具的用法:將foo庫中的表t1導出成json格式:[root@localhost bin]# ./mongoexport -d foo -c t1 -o /data/t1.json connected to: 127.0.0.1 exported 1 records [root@localhost bin]# 導出成功後我們看一下/data/t1.json文件的樣式,是否是我們所希望的:[root@localhost data]# more t1.json { “_id” : { “$oid” : “4f927e2385b7a6814a0540a0” }, “age” : 2 } [root@localhost data]# 通過以上說明導出成功,但有一個問題,要是異構資料庫的遷移怎麼辦呢?
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/248592.html