How to connect to mongoDB

1 visualización (últimos 30 días)
Byri Manoj
Byri Manoj el 30 de Jul. de 2023
Respondida: the cyclist el 31 de Jul. de 2023
I have no idea how to connect the mongoDB with matlab. The matlab documentation gives the following code but what to we give as server? I got connection string from my cluster but how do I connect with matlab? Please answer!
PS: I have the MATLAB Database Toolbox installed. I refered the https://www.mathworks.com/help/database/document-database.html link too.
server = "dbtb01";
port = 27017;
dbname = "mongotest";
conn = mongoc(server,port,dbname)
Error using database.mongo.connection
[Mongo Driver Error]: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'dbtb01'].

Error in mongoc (line 52)
conn = database.mongo.connection(varargin{:});

Respuestas (1)

the cyclist
the cyclist el 31 de Jul. de 2023
These are questions that should be able to be answered by whoever set up the MongoDB in the first place. But, here are a couple guesses.
If the database is on your local machine where you are running MATLAB, you should be able to use
server = "localhost";
If it is not, then you need to ask the person who set the database up for the server name.
The default port for MongoDB is 27017, so that should be fine (unless the person who set the database up changed it).
You will need to know the name of the database you are trying to access. Again, whoever set the db up should know that.
(It is possible you will also need a username and password, but not until you succeed at finding the server.)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by