如何通过名称访问MongoDB数据库;mongodb://127.0.0.1/testDatabase"
我想知道如何设置mongoDB数据库,以便我可以使用以下名称访问它:mongodb://127.0.0.1/testDatabase“ 我什么也没找到,因为我不知道它的主题如何通过名称访问MongoDB数据库;mongodb://127.0.0.1/testDatabase",database,mongodb,nosql,Database,Mongodb,Nosql,我想知道如何设置mongoDB数据库,以便我可以使用以下名称访问它:mongodb://127.0.0.1/testDatabase“ 我什么也没找到,因为我不知道它的主题 谢谢 你能提供更多细节吗?您尝试访问MongoDB的方式和位置?是否要设置新的MongoDB数据库并连接到它? Connect to Mongodb Instance: In the following example, the URI connection string specifies connecting t
谢谢 你能提供更多细节吗?您尝试访问MongoDB的方式和位置?是否要设置新的MongoDB数据库并连接到它?
Connect to Mongodb Instance:
In the following example, the URI connection string specifies connecting to a
MongoDB instance that is running on localhost using port 27017.
The myproject indicates the database to use.
If the database is omitted, the MongoClient uses the default test database:
var MongoClient = require('mongodb').MongoClient
, assert = require('assert');
// Connection URL
var url = 'mongodb://localhost:27017/myproject';
// Use connect method to connect to the server
MongoClient.connect(url, function(err, db) {
assert.equal(null, err);
console.log("Connected successfully to server");
db.close();
});