3 years ago
Hello, I have a question, can I change mongodb default database name? Its "test" right now. I'd preferably like to name it something like "prod". How can I do this?
11 Replies
3 years ago
just hit the little plus button and add a database named "prod"
I see, but then how can I fill that database with data? If I have both a "test" and a "prod" database how does my request create collections in the correct database.
Also, is there a way to copy over data from the test to the prod db? I already have a bunch of data that I don't want to recreate manually if possible.
3 years ago
- youd specify the database you want to use when connecting to mongo
- youd have to mongodump test and mongorestore the dump to prod
Do you have any examples for how to do the mongodump test and mongorestore? I'm not too sure how I would be able to interact and run these commands with the database in railway
3 years ago
hello... i seem to have the same problem except.... when i create a new database and enter the new db name in the connection string i get the error "Authentication failed"
2 years ago
please read the mongoose docs, you need to specify the database name in the connection options
according to mongo specs, the connection string should be mongodb://[username:password@]host1[:port1][/[defaultauthdb][?options]]
this is exactly what i'm doing, appending the new db name to the private connection string provided by railway... am I missing something?
2 years ago
as mentioned previously, please read mongoose docs, you need to specify the database name in the connection object, not the url