Change MongoDB default database name
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?
12 Replies
Project ID:
N/A
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.
1. youd specify the database you want to use when connecting to mongo
2. 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
thank you, I'll let you know if I have more questions
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"
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?
as mentioned previously, please read mongoose docs, you need to specify the database name in the connection object, not the url
got it... thanks!