3 months ago
I am new to Railway and seem to keep getting stuck. I created a MySql database, renamed it from railway to tanks_db, redeployed (and restarted). I then use the credentials to connect from MySQL workbench. Workbench shows only a database called 'railway'.
When I go to the database tab in Railway - it gives me the error unable to connect to database 'unknown database tanks_db'. I have checked and in variables MYSQL_DATABASE is still tanks_db.
Any idea where I went wrong or how to fix? Thank you in advance.
Pinned Solution
3 months ago
Not sure if I was clear enough, but you can think of Railway as just a layer on top of what is actually running underneath.
The database itself lives inside its own “capsule”, and Railway only exposes a configuration layer around it.
So even if you change the database name in that outer layer, it doesn’t change what already exists inside the capsule.
8 Replies
3 months ago
Hey!
This seems like an issue with your project/application, the database you are trying to connect is called tanks_db but only the one called railway exists. Unfortunately, we're unable to offer support for issues unrelated to the Railway product or platform but our community might be able to help debug that!
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
Hello!
Could you please tell me where have you renamed it? Maybe a screenshot would help.
Thanks
3 months ago
3 months ago
Thanks!
The MYSQL_DATABASE variable in Railway only tells your application which database name it should connect to — it doesn’t actually create or rename the database inside MySQL.
What you can do is:
- Keep the MYSQL_DATABASE variable set to tanks_db in your Railway settings.
- Connect to the MySQL server as root using MySQL Workbench (or any other client), with the MYSQL_ROOT_PASSWORD and the server host/port provided by Railway.
- Once connected, create the database manually by running:
CREATE DATABASE tanks_db;
After that, the tanks_db database should exist, and your application (as well as the Railway “Database” tab) should be able to connect to it normally.
aronrissato
Thanks!The MYSQL_DATABASE variable in Railway only tells your application which database name it should connect to — it doesn’t actually create or rename the database inside MySQL.What you can do is:- Keep the MYSQL_DATABASE variable set to tanks_db in your Railway settings.- Connect to the MySQL server as root using MySQL Workbench (or any other client), with the MYSQL_ROOT_PASSWORD and the server host/port provided by Railway.- Once connected, create the database manually by running:CREATE DATABASE tanks_db;After that, the tanks_db database should exist, and your application (as well as the Railway “Database” tab) should be able to connect to it normally.
3 months ago
Not sure if I was clear enough, but you can think of Railway as just a layer on top of what is actually running underneath.
The database itself lives inside its own “capsule”, and Railway only exposes a configuration layer around it.
So even if you change the database name in that outer layer, it doesn’t change what already exists inside the capsule.
aronrissato
Thanks!The MYSQL_DATABASE variable in Railway only tells your application which database name it should connect to — it doesn’t actually create or rename the database inside MySQL.What you can do is:- Keep the MYSQL_DATABASE variable set to tanks_db in your Railway settings.- Connect to the MySQL server as root using MySQL Workbench (or any other client), with the MYSQL_ROOT_PASSWORD and the server host/port provided by Railway.- Once connected, create the database manually by running:CREATE DATABASE tanks_db;After that, the tanks_db database should exist, and your application (as well as the Railway “Database” tab) should be able to connect to it normally.
3 months ago
Wonderful thank you! I will get this! So if I have multiple databases in this single capsule - can I reference them all from the outer layer? It is confusing there is only one place for a database name within the capsule when I am able to set up multiple. Thank you!
aronrissato
Not sure if I was clear enough, but you can think of Railway as just a layer on top of what is actually running underneath.The database itself lives inside its own “capsule”, and Railway only exposes a configuration layer around it.So even if you change the database name in that outer layer, it doesn’t change what already exists inside the capsule.
3 months ago
Status changed to Solved noahd • 3 months ago

