Cannot change/add mongo db database name

seniorramonHOBBY

a year ago

I want to add a mongo db database called chat and connect to it.

I tried to use this URL in my backend:

mongodb://user:pass@service:port/chat

but it gives Error: MongoServerError: Authentication failed.

I have tried everything but nothing seems to work.

PS: Im using express.

4 Replies

a year ago

How have you gone about adding that database name?


mitchell8210HOBBY

a year ago

I also am running into issues with changing the name of the db for mysql. It seems that the default name is 'railway' but when i edit the MYSQL_DATABASE env var in the variable list and redeploy, even though the other variables are auto synched to match that new name the connection is refused with the following error: ERROR 1049 (42000): Unknown database 'new-db-name'. After reverting that same MYSQL_DATABASE env var and redeploying again it allows me to connect to the db where the name of the db is 'railway'. I wonder if there is something extra the user needs to change/configure for this to work but cannot seem to find anything regarding the name of the db in the docs. (this is not a dealbreaker for me just hoping there is a legitimate way to change the db name to something I would prefer instead of the default name)


a year ago

You can not change the database name by the variable, but they are standard MySQL databases so you'd change the name the same way you would any MySQL database.


mitchell8210HOBBY

a year ago

Ok, so after some research about how to change a mysql database name I have found that a user must do a mysqldump, create a new db with the desired name, and then import the dump file into the newly created db and drop the old db. I have opened a new thread regarding a feature request to be able to specify the database name for a new database service in the feedback section, not expecting it anytime soon but just think that it may improve the UX a bit by removing the need to do the change manually if the user would prefer a custom db name.