Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过名称访问MongoDB数据库;mongodb://127.0.0.1/testDatabase"_Database_Mongodb_Nosql - Fatal编程技术网

如何通过名称访问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://127.0.0.1/testDatabase“

我什么也没找到,因为我不知道它的主题


谢谢

你能提供更多细节吗?您尝试访问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();
});