In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Generally speaking, mongoexport export is used for collection, while Mongodump can be a single table or an entire library. At the same time, the JSON output of mongoexport is more readable than the BSON of Mongodump. JSON files can be read directly, and the splicing instructions can be operated to restore data by insert.
-- back up a single table (user lych, password abcde, exported aaa collecion in lych_ database)
Mongodump-u lych-p abcde-- port 27017-- authenticationDatabase admin-d lych_db-c aaa-o / tmp/abc.bak
-to back up a single database, remove the above-c aaa
-while backing up all libraries, remove-d lych_db
(--it is recommended to use the parameter "add-- oplog" (based on snapshots at a certain point in time) to back up all libraries, which can only be used to back up all libraries. Single database and single table are not applicable:
Mongodump-h 127.0.0.1-- port 80000-- oplog-o / tmpt/abc.bak (some configuration files can be configured for bond_ip, please note)
-- add-- oplogReplay parameter when restoring:
Mongorestore-h 127.0.0.1-- port 80000-- oplogReplay / tmp)
-- restore a single library:
Mongorestore-u xx-p xxx-- port 80000-- authenticationDatabase admin-d xxx / tmp
-- restore all libraries:
Mongorestore-u superuser-p 123456-- port 80000-- authenticationDatabase admin / tmp/bak
(if you add the-- gzip parameter when backing up, then you should also take-- gzip when restoring.)
-- restore single tabl
Mongorestore-u xxx-p xxx-- authenticationDatabase admin-d xxx-c xx / xxx.bson
Mongorestore is appended by default. After the-- drop parameter, the database data will be emptied and then imported. If new data is added after the database backup, the newly added data will also be deleted.
-mongo can also be backed up when it is closed. You only need to find the data directory:
Mongodump-dbpath / data/db
Mongodump exports bson format and binary format, but you can use the bsondump command that comes with mongo to view the data, while mongoexport exports text, which can be in csv or json format.
JSON is highly readable but large, while BSON is a binary file, small but almost non-readable.
Among some mongodb versions, the BSON format may vary from version to version, so using mongodump/mongorestore between different versions may not be successful, depending on the compatibility between versions. When you cannot use BSON for cross-version data migration, using the JSON format, or mongoexport/mongoimport, is an option.
Cross-version mongodump/mongorestore is not recommended personally. To do this, please check the documentation to see if the two versions are compatible (most of the time).
Although JSON has good cross-version versatility, it only retains the data part and does not retain other basic information such as index, account and so on. Attention should be paid when using it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.