<p>The most usual strategy is a direct connection from application (java, php, c#, python, ruby, etc) to the database (mysql, oracle, sql server, postgres, mongo, etc)</p>
<p>In your development stage, your app and database are in your laptop. In this scenario is not common to apply security regulations.</p>
<p>In the next stages like testing, staging, uat, production, etc the security should be applied:</p>
<ul>
<li>Developers should not know the database credentials of another environments, especially <strong>production</strong></li>
<li>Database credentials should not be in the source code. The application should use configurations files or environment variables.</li>
<li>Database must be under ssl</li>
</ul>
<p>With these security regulations or standards, you will not need crazy and unmaintainable database switch to <strong>protect</strong> your final database.</p>

CC BY-SA 4.0
2021-07-27T14:04:14.640Z
2021-07-27T14:04:14.640Z
JRichardsz
<p>From my experience I have used proxy servers to refer to different servers (nginx).</p>
<p>I have previously worked on building a mvc framework.
Basically there were 8 databases with 10 accounts each. The main database had the server addresses and db credentials for each of the other databases. Whenever a user logged in, the main db will disconnect and connect to the appropriate user database.</p>
<p>I was wondering if there in a more common way to do that other than hard-coding this to the database class(s).</p>
<p>I have been thinking about proxy servers that basically refer a user to servers. So maybe it's possible to do the same but for db servers? (Just a thought..)</p>

CC BY-SA 4.0
2021-07-26T14:24:56.463Z
#1 is the database switch handled with a programming language or at database level? #2 How do you handle the database connection pool? #3 What is the goal of that strategy? Hide the real ip/user/password of database instances?
JRichardsz
CC BY-SA 4.0
2021-07-26T21:13:08.973Z
#1 with the programing language. if user credentials are verified I disconnect from the main db and connect to the right user db #2 fetch user credential inputs and validate them within the main database, if they match: get the user logged in by disconnecting from the main db and connecting to the user db where all his/her data exist. user db credentials are in the main db. #3 yes. This project belonged to an over 10 years company with really old code. i don't believe there is a strategy behind this. I just want to understand what is the common "modern" way to navigate between db. @JRichardsz
Kar19
<databases>
Is it possible or common to use a Proxy server to refer to a database
Kar19
# Is it possible or common to use a Proxy server to refer to a database

(Asked by: username_0 on 2021-07-26)

From my experience I have used proxy servers to refer to different servers (nginx).

I have previously worked on building a mvc framework.
Basically there were 8 databases with 10 accounts each. The main database had the server addresses and db credentials for each of the other databases. Whenever a user logged in, the main db will disconnect and connect to the appropriate user database.

I was wondering if there in a more common way to do that other than hard-coding this to the database class(s).

I have been thinking about proxy servers that basically refer a user to servers. So maybe it's possible to do the same but for db servers? (Just a thought..)

**Tags:** databases

> **Comments:**
> **username_1**: #1 is the database switch handled with a programming language or at database level? #2 How do you handle the database connection pool? #3 What is the goal of that strategy? Hide the real ip/user/password of database instances?  
> **username_0**: #1 with the programing language. if user credentials are verified I disconnect from the main db and connect to the right user db #2 fetch user credential inputs and validate them within the main database, if they match: get the user logged in by disconnecting from the main db and connecting to the user db where all his/her data exist. user db credentials are in the main db. #3 yes. This project belonged to an over 10 years company with really old code. i don't believe there is a strategy behind this. I just want to understand what is the common "modern" way to navigate between db. @username_1  

---

## 1 answers

### Answer by username_1 on 2021-07-27. Score: 2 | Accepted answer

The most usual strategy is a direct connection from application (java, php, c#, python, ruby, etc) to the database (mysql, oracle, sql server, postgres, mongo, etc)

In your development stage, your app and database are in your laptop. In this scenario is not common to apply security regulations.

In the next stages like testing, staging, uat, production, etc the security should be applied:

* Developers should not know the database credentials of another environments, especially **production**
* Database credentials should not be in the source code. The application should use configurations files or environment variables.
* Database must be under ssl

With these security regulations or standards, you will not need crazy and unmaintainable database switch to **protect** your final database.


---

