Replica Set not getting created I have database which is set up in data folder of mongodb. For accessing this database I usually run the below command 

    mongod --dbpath "C:\program files\mongodb\data" --port 27017


Now I am trying to replicate database. For creating Primary database I run command

    mongod --port 27017 --dbpath "C:\Program Files\MongoDB\data" --replSet replicaSetMGL --smallfiles --oplogSize 128


I have created two empty folders in mongodb folder as replicaSet1 and replicaSet2. Now for creating replica set for port no. 27018, I executed below command in another terminal.

    mongod --port 27018 --dbpath "C:\Program Files\MongoDB\replicaSet1" --replSet replicaSetMGL --smallfiles --oplogSize 128


This is not working (throwing error):

C:\Users\well come&gt;mongod --port 27018 --dbpath "C:\Program Files\MongoDB\replic
aSet1" --replSet replicaSetMGL --smallfiles --oplogSize 128
2017-06-12T17:25:33.164+0530 I CONTROL  [initandlisten] MongoDB starting : pid=6
936 port=27018 dbpath=C:\Program Files\MongoDB\replicaSet1 64-bit host=hp
2017-06-12T17:25:33.164+0530 I CONTROL  [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] db version v3.4.4
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] git version: 88839051587
4a9debd1b6c5d36559ca86b44babd
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] OpenSSL version: OpenSSL
 1.0.1u-fips  22 Sep 2016
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] modules: none
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] build environment:
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     distmod: 2008plus-ss
l
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     distarch: x86_64
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] options: { net: { port:
27018 }, replication: { oplogSizeMB: 128, replSet: "replicaSetMGL" }, storage: {
 dbPath: "C:\Program Files\MongoDB\replicaSet1", mmapv1: { smallFiles: true } }
}
2017-06-12T17:25:33.166+0530 I -        [initandlisten] Detected data files in C
:\Program Files\MongoDB\replicaSet1 created by the 'wiredTiger' storage engine,
so setting the active storage engine to 'wiredTiger'.
2017-06-12T17:25:33.167+0530 I STORAGE  [initandlisten] wiredtiger_open config:
create,cache_size=3557M,session_max=20000,eviction=(threads_min=4,threads_max=4)
,config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal
,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,lo
g_size=2GB),statistics_log=(wait=0),
2017-06-12T17:25:34.184+0530 W STORAGE  [initandlisten] Detected configuration f
or non-active storage engine mmapv1 when current storage engine is wiredTiger
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten]
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten] ** WARNING: Access contr
ol is not enabled for the database.
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten] **          Read and wri
te access to data and configuration is unrestricted.
2017-06-12T17:25:34.186+0530 I CONTROL  [initandlisten]
2017-06-12T17:25:34.308+0530 I FTDC     [initandlisten] Initializing full-time d
iagnostic data capture with directory 'C:/Program Files/MongoDB/replicaSet1/diag
nostic.data'
2017-06-12T17:25:34.447+0530 I REPL     [initandlisten] Did not find local voted
 for document at startup.
2017-06-12T17:25:34.448+0530 I REPL     [initandlisten] Did not find local repli
ca set configuration document at startup;  NoMatchingDocument: Did not find repl
ica set configuration document in local.system.replset
2017-06-12T17:25:34.451+0530 I NETWORK  [thread1] waiting for connections on por
t 27018
OK.. It's look like that you have managed to mix things. So, you have working mongodb at "C:\program files\mongodb\data" and now you want to convert that mongodb to three node replica set?!?
First after you have start that mongod process with --replSet replicaSetMGL parameter. Log in (with mongo -program) and give command rs.initiate().

Then remove all files from directory "C:\Program Files\MongoDB\replicaSet1" (because I can see from log file that there is mixed db files; mmapv1 and wiredTiger). Start that node with those parameters.

Go back to first nodes mongo and give command rs.add("localhost:27018") to add that node to replica set. With command rs.status() you can see your replica sets status.

Repeat those steps to add third node to RS.