Accidentally connected the wrong MySQL database and need to recover the original database
laura2024macrodent
PROOP

a month ago

Hello Railway Support,

I accidentally connected the wrong MySQL database to one of my services, and I am trying to recover the original database/volume.

The affected project is Backend Bloques Cf Macrodent, and the affected service is controlfresadoras.

Originally, this service was connected to a MySQL database that contained tables such as:

operario

productos

lotes_productos

historial_productos

After making some changes, the service was accidentally connected to another MySQL database that belongs to a different application. That database contains tables such as pacientes, facturas, roles, and mensajes_trabajo.

The application is now returning this error:

Error: Table 'railway.operario' doesn't exist

SQL: SELECT * FROM operario WHERE username = '...'

The database connection itself works, but it is clearly connecting to the wrong MySQL database.

I did not have Railway Backups enabled for the original database.

I would like to know if the previous MySQL volume/database still exists, was detached, or is currently in the deletion recovery period. If possible, I need help recovering or reconnecting the original volume that contained the operario, productos, lotes_productos, and other related tables.

The issue happened approximately within the last 1–2 days.

Please let me know if you need the Project ID, Service ID, volume information, screenshots, or any other details to locate the previous database.

Thank you very much for your help.

$20 Bounty

4 Replies

Railway
BOT

a month ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 1 month ago


Do you have multiple MySQL databases in the project? Did you change any reference variables? And did you delete any database/volume?

These questions should help clarify what went wrong.


darseen

Do you have multiple MySQL databases in the project? Did you change any reference variables? And did you delete any database/volume? These questions should help clarify what went wrong.

laura2024macrodent
PROOP

a month ago

Yes. I have another MySQL database for a different application (my STL system), and I believe I accidentally changed the database connection variables in the controlfresadoras service so that it now points to the STL MySQL database instead of its original MySQL database.

The controlfresadoras service currently has variables such as DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DB_DATABASE, and I believe these were modified when I connected the other database.

The wrong database is working and contains tables such as pacientes, facturas, roles, and mensajes_trabajo, which belong to the STL application.

The original database for controlfresadoras should contain tables such as operario, productos, lotes_productos, historial_productos, etc.

I do not remember intentionally deleting the original MySQL database or its volume. I may have accidentally replaced, detached, or removed the original connection while connecting the other MySQL database. I checked the Activity history, but I have not found a clear event showing that the original volume was deleted.

I also did not have backups enabled.

What I need help with is determining whether the original MySQL database/volume still exists, is detached, or was recently deleted and can still be recovered.

The issue happened within the last 1–2 days.


If you just changed the reference variable for the DATABASE_URL, then your database is totally fine. You just need to modify the DATABASE_URL variable of the service that connects to the db to point to its original db again. You can achieve this by setting DATABASE_URL=${{<DB SERVICE NAME.DATABASE_URL}}. Note that db service name should be set to whatever your database service name is.


darseen

If you just changed the reference variable for the DATABASE_URL, then your database is totally fine. You just need to modify the DATABASE_URL variable of the service that connects to the db to point to its original db again. You can achieve this by setting `DATABASE_URL=${{<DB SERVICE NAME.DATABASE_URL}}`. Note that db service name should be set to whatever your database service name is.

laura2024macrodent
PROOP

a month ago

That wasn't it; I uploaded a database to the STL project, and it was uploaded to both the STL project and the controlfresadoras project, thereby deleting the database that shouldn't have been deleted.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...