Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with mongoRestore [listCollections requires authentication]

I am trying to restore a MongoDB on an EC2 instance. I am currently running Mongo 4.0. I am restoring a .tgz, which I then unzip, and it contains a directory with all of my files. I previously used this command:

sudo mongorestore --db newDB mongoDump-2018-07-25-0200/viboDB/

Now that I am trying to update our database, I am getting the following error.

building a list of collections to restore from mongoDump-2018-07-25/0200 dir
Failed: viboBI2.Songs: error reading database: command listCollections requires authentication

I have logged into the mongo shell, and used db.auth() to authenticate as an admin. I have tried restarting mongo as well. Any help would be appreciated!

like image 999
DrummerGenius Avatar asked Aug 06 '18 19:08

DrummerGenius


1 Answers

For restoring the Database you need to provide authentication.

mongorestore -u USERNAME -p PASSWORD --authenticationDatabase admin -d dbNAME PATH/TO/DIRECTORY

you can also provide host and port by adding -h and --port

like image 198
Anurag Dhunna Avatar answered Nov 16 '22 19:11

Anurag Dhunna