Home / Learn Secure SQL / Secrets Management

Secrets Management

Where database passwords and connection strings should actually live.

The gistWhere database passwords and connection strings should actually live.

The idea, explained simply

Two ways to store credentialsHard-coded / committedto gitVisible in every clone, fork,and backup foreverRotating means a code changeand redeployA secrets managerFetched at runtime, neverstored in codeRotated independently of anydeployment
Two ways to store credentials

In plain terms

A secrets manager (such as a cloud provider's secret store, HashiCorp Vault, or similar) stores database credentials securely and lets an application fetch them at startup, rather than the credentials being hard-coded or committed to source control.

Why we use it

Credentials committed to a repository (even a private one) tend to leak eventually — through a fork, a backup, a misconfigured permission, or simply years of history — while a secrets manager can rotate and audit access to credentials independently of the application's codebase.

Under the hood

Store database credentials in a secrets manager or at minimum environment variables outside version control, fetch them at application startup, and rotate them periodically without needing a code change.

Real-world use

  • Web application code review
  • Backend development
  • Database administration
Careful:A database password or connection string ever appearing in a git commit should be treated as permanently compromised — rotating the credential is the correct response, not simply deleting the commit, since history can persist in clones and forks.

Quick quiz

1. Database credentials are best stored...