MYSQL資料庫資料匯入mongoDB

2021-06-18 06:59:29 字數 821 閱讀 4599

為測試mondodb與mysql資料效能對比,需要先將存在mysql中的資料匯入到mongodb中。

基本流程是:

1. 先將mysql資料匯入到文字中

2.利用mongodb的資料匯入工具將資料匯入到mongodb中

具體操作如下:

1. 進入mysql資料資料庫,這裡的資料庫名稱是robinhood_afs. 將該資料庫中的資料表entries中的資料匯出,儲存為/tmp/entries.json(有些其他路徑可能沒有許可權寫,要注意),命令如下:

select * from entries into outfile '/tmp/entries.json' fields terminated by ',' lines terminated by '\n';

(總共查詢5240595rows,花費7min58.24sec)

2. 當第一步操作完成後,在/tmp目錄下,可以看到entries.json檔案。接下來需要呼叫mongodbimport工具將資料匯入到mongodb,命令如下:

/usr/bin/mongoimport --port 27020 -d bigdata -c entries  --type csv --ignoreblanks  -f "id,parent_id,fullpath,owner,gr_name,size,blocks,last_access,last_mod,type,md_update,path_update,invalid,whitelisted,release_class,rel_cl_update" -file '/tmp/entries.json'

由此,遷移完成

參考:

mysql資料庫匯出匯入 mysql資料庫匯入匯出

匯出 mysqldump u 使用者名稱 p 資料庫名 匯出的檔名 匯出整個資料庫 mysqldump u dbuser p dbname dbname.sql all databases 備份伺服器上所有資料庫 mysqldump u dbuser p all databases allbacku...

Mysql匯入資料庫

網上查的都是用命令列,匯入資料的,自己發現用mysql的workbench匯入非常簡單 1.在server administration中選取manage import export 2.選擇data import restore,options選取import from self containe...

MySQL 資料庫匯入

先導出資料庫 然後cmd到匯出的sql檔案路徑下,進到mysql命令列,執行如下操作 webviewer是任意庫名 drop database if exists webviewer create database if not exists webviewer use webviewer sour...