shell导出mysql到mongo

前端之家收集整理的这篇文章主要介绍了shell导出mysql到mongo前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
# MysqL导出tsv格式文件

MysqL -hlocalhost -uUSER -pPASSWORD -e "select id,name,age,sex from DB_NAME.users where age>10 into outfile '/tmp/xxxx.tsv' fields terminated by '\t' optionally enclosed by '' escaped by '' lines terminated by '\r\n';"

#mongoimport 把tsv文件数据导入mongodb

mongoimport -h localhost -u USER -p PASSWORD -d DB_NAME -c user_collection --columnsHaveTypes --type tsv --file '/tmp/xxxx.tsv' -f id.int\(\),name.string\(\),age.int\(\),sex.int\(\),created_date.date_ms\('yyyy-MM-dd H:mm:ss'\)
原文链接:https://www.f2er.com/bash/390186.html

猜你在找的Bash相关文章