MongoDB error local.oplog.rs is not empty on the initiating member. cannot initiate

Error when initiating replica set with some old data in local database:

rs.initiate() 
{
"errmsg" : "local.oplog.rs is not empty on the initiating member. cannot initiate.",
"ok" : 0
}

Solution:

use local

db.oplog.rs.drop()