By asking this kind of question i highly recommend you to first read into the basics of web-security!! :)
Sending credential´s over the web to your server for it to access a database is an absolut no-go.
- Your webserver stores the credential´s in a seperate file which is not accessible through the web. You can do that by having the credential-file outside of the document-root of your webserver.
- Furthermore: Your DB-Server should only accept communication from trusted IP`s. If youre web-app instance and DB-instance are on the same server, only accept from localhost.
You probably want to authenticate youre app-clients for limiting the accessibility of your database calls. Commonly you send the clients credential
s once, which the server validates and responds with an auth-token. For any further communication the token is used, which invalidates after defined period of time. (Token-Based Authentication)
The idea is to minimize the exposed time frame of the credential`s. Even if you use SSL encryption for.
Best of luck
Hannes