Forum

You are not logged in.

#1 06-02-2018 20:39:39

oric_dev
Membre
Registered: 28-01-2018
Posts: 4

MongoDb: how to start (using a dumped .bson file to restore)

Hello, i want to use a dumped bson file to initialize my MongoDb (which I can restore with mongorestore). My website is called "tuttifrutti".
Is this possible ?
I suspect i have to create it from scratch by re-creating its content via MongoClient (Python).

So far, here are the steps I followed:
- i created in my admin interface a new MongoDb database (tuttifrutti_off)
- on top appears the comment "Hôte MongoDB : mongodb-tuttifrutti.alwaysdata.net"
- on Python, I tried using MongoClient("mongodb://tuttifrutti:<password>@mongodb-tuttifrutti.alwaysdata.net") but it fails with "authentication failed".
so I tried without login:password, but when trying to create a collection it states 'not authorized on tuttifrutti_off to execute command { listCollections: 1, cursor: {} }'

Questions:
- what login should I use for accessing the mongo-db? shall I use the same login as the name of my website and my home directory?
- can I access the host "mongodb-tuttifrutti.alwaysdata.net" via ssh or whatever, in command line I mean, in order to perform the mongorestore command?
- how can I restore my bson db?
- where is the mongodb stored ? apparently not within my home directory
All this is a bit mysterious.

Thanks for any support.
kind regards, Olivier.

Last edited by oric_dev (06-02-2018 21:41:56)

Offline

#2 07-02-2018 11:19:46

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,638
Website

Re: MongoDb: how to start (using a dumped .bson file to restore)

Hello,

oric_dev wrote:

- what login should I use for accessing the mongo-db? shall I use the same login as the name of my website and my home directory?

You can manage your MongoDB users in the Databases > MongoDB > User management section. By default, you already have a user having the same name as your account (i.e. tuttifrutti).

oric_dev wrote:

- can I access the host "mongodb-tuttifrutti.alwaysdata.net" via ssh or whatever, in command line I mean, in order to perform the mongorestore command?

Yes, this command should work:

mongo -p -u tuttifrutti mongodb-tuttifrutti.alwaysdata.net/tuttifrutti_off
oric_dev wrote:

- how can I restore my bson db?

Using mongorestore, which is already installed on our servers.

oric_dev wrote:

- where is the mongodb stored ? apparently not within my home directory

MongoDB runs on a shared server you can only access remotely. You cannot access the data files directly.

Offline

#3 08-02-2018 21:36:41

oric_dev
Membre
Registered: 28-01-2018
Posts: 4

Re: MongoDb: how to start (using a dumped .bson file to restore)

Bonjour Cyril, merci pour toutes ces informations smile.

Actually, when I am trying the advised connection command you've been provided, I get an authorization failure message, even though I am sure to use the correct password. I created a new user also to get more sure, but still the connection fails.

--> $ mongo -p -u tuttifrutti mongodb-tuttifrutti.alwaysdata.net/tuttifrutti_off                                                                             
MongoDB shell version: 2.6.10                                                                                                                                     
Enter password:
connecting to: mongodb-tuttifrutti.alwaysdata.net/tuttifrutti_off
2018-02-08T20:57:16.563+0100 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1287
exception: login failed
--> olivier@heracles:~

User has full access. It behaves as if the database tuttifrutti_off did not exist (or not initialized?). Is it sufficient to create a document through the interface (databases > MongoDb > add a database), or is another step required?

Did I miss something?

thanks for help & kind regards, Olivier.

Offline

#4 09-02-2018 09:23:06

@Cyril
Staff
From: Paris
Registered: 06-02-2007
Posts: 5,638
Website

Re: MongoDb: how to start (using a dumped .bson file to restore)

I thought you were using the 'mongo' command on our SSH servers, but you're running it locally. It's too old (2.6.10) to work with latest MongoDB versions, you need to upgrade.

Offline

#5 12-02-2018 21:44:12

oric_dev
Membre
Registered: 28-01-2018
Posts: 4

Re: MongoDb: how to start (using a dumped .bson file to restore)

This is actually working fine directly on ssh server.. based on the syntax of the mongo command to use, I did not imagine it could be used directly on the server. Thanks a lot for having helped! It works very fine now.

Offline

Board footer

Powered by FluxBB