After following the docs listed below I am unable to access my database. I most definitely did not forget my password as I actually saved the query that I ran to create the user I will list the query I ran below.
I get the following error when I try to connect my local host instance in MongoDB compass
connect ECONNREFUSED 127.0.0.1:27017
use admin
db.createUser(
{
user: "max",
pwd: "max",
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
]
}
)
I need help accessing my local database and if possible setting up authentication on the schema
Start a standalone mongod instance without access control. Open a terminal and run the following command as the mongod user:
mongod --port 27017 --dbpath /var/lib/mongodb
The mongod instance in this tutorial uses port 27017 and the /var/lib/mongodb data directory.
The tutorial assumes that the /var/lib/mongodb directory exists and is the default dbPath . You may specify a different data directory or port as needed.
TIP When mongod starts, it creates some system files in the /var/lib/mongodb directory. To ensure the system files have the correct ownership, follow this tutorial as the mongod user. If you start mongod as the root user you will have to update file ownership later.
mongosh --port 27017
If you are connecting to a different deployment, specify additional command line options, such as --host , as needed to connect.
I made sure that I made a user
Using mongosh switch to the admin database add the myUserAdmin user with the userAdminAnyDatabase and readWriteAnyDatabase roles":
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: passwordPrompt(), // or cleartext password
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
]
}
)
I just uninstalled and reinstalled both MongoDB and MongoDB compass.