Linux environment, through the Mongofiles file operation MongoDB:
Using the--uri parameter, you can create a short connection that is easy to use in your program and does not need to be initialized or disconnected after the end.
The official format is
mongodb://[username:password@]host1[:p ort1][,host2[:p Ort2],... [, hostn[:p Ortn]]] [/[database][?options]]
Reference address: Connection String URI Format
which
1. "mongodb://": the standard opening of the URI
2. "username:password@": Connection MongoDB the user name and the password which uses, if MongoDB does not turn on the user authentication, then does not fill also may operate successfully. If username/password is present, it needs to be prefixed with the last delimiter @
3. "Host1": Remote logins of the host IP, if it is even their own host, 127.0.0.1 can be.
4. ":p Ort1": The remote host port to log on, default to 27017 if not filled
5. "Hostn:portn": if there are more than one need to log on to the host IP, then separated by commas.
6. "Database": Need to operate the name of the MongoDB, if not filled out, the default is the admin database.
7. "Options": Additional parameters, specific parameters specified please check the reference address above, or the following example (3) how to use.
Example:
(1) with the username testuser, password is testpwd, login 127.0.0.1 (local) on the active database, and call the List command to view the data.
./mongofiles--uri mongodb://testuser:testpwd@127.0.0.1:27017/active List
(2) If there is no certification requirements, and view the admin database, you can simplify to
./mongofiles--uri mongodb://127.0.0.1 List
(3) in the mongodb3.0 version of the default use of the SCRAM-SHA-1 certification, if you need to adjust the MongoDB host side of the authentication method, you can refer to the Web site: mongodb3.03 open authentication, and if you need to adjust the client side of the transmission of the past authentication methods, you can increase the options Parameter implementation.
./mongofiles--uri MONGODB://TESTUSER:TESTPWD@127.0.0.1:27017/?AUTHMECHANISM=MONGODB-CR delete_id 111
Use & to separate multiple options parameter designations.
Problems in the process of using:
The invocation of the command in example (1) in the course of the actual use encountered a problem:
When all other parameters, such as username and password, are correct, view the logs in MongoDB, where the error message is:
Usernotfound:could not find User xxx@test
where xxx is the user name used, and after @ is the database name, meaning that the test database can not find the XXX user, that is, the user does not exist or do not have permission to operate. The problem is that the corresponding database active is indeed specified in the parameter, and the database side is still judged to be the test database.
The problem has not been identified for the time being, whether it is a special case or a general situation. The alternative is to use-D to specify the corresponding database, which is
./mongofiles-d Active--uri mongodb://testuser:testpwd@127.0.0.1:27017 list
In this way, the command executes successfully.
Related Operations Command:
List: Listing database data
PUT/PUT_ID: Save file/and specify ID
get/get_id: Remove files according to filename/id
DELETE/DELETE_ID: Delete files according to filename/id
Specific reference Documentation: Mongfiles
In addition Linux without the configuration file directly start MongoDB:
bin/mongod-dbpath/data/mongo/-logpath/data/mongo/mongo.log-logappend-fork-port 27017
Later the way executes.