Run without authentication:
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] })
db.createUser({
user: "admin",
pwd: "securepassword123", // Use a strong password
roles: [ { role: "root", db: "admin" } ]
})
Start again with authentication:
mongosh --port 27017 -u admin -p securepassword123 --authenticationDatabase admin