I am creating a MongoDB database through a linux terminal and I am trying to create a collection for the database.
But when I run the command: db.createCollection("mainCollection")
I get the following error message: { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
I'm not exactly sure what this means. How can I make the database master?
Thanks
You have started the
mongod
with the --replSet option (or equivalent configuratin file option). That puts themongod
into a mode where it will not allow any writes until it receives a replica set configuration.For an existing replica set this is accomplished by doing a rs.add("<host>:<port>") on the existing primary for the replica set.
Based on the conversation around this question I think you have a single MongoDB instance and do not plan to have a true multi-member replica set. If that is the case you have two options:
mongod
.mongod
process.mongod
process without the--replSet
option on the command line/config.mongod
as a single node replica set.