Database Credentials in Code Repos: Move to Environment Variables
Secrets.
Database passwords committed to a code repository stay in its history even after you delete them. Move them to environment variables and rotate them.
Step 1: Find the credentials

Search the code and history for DB_PASSWORD, password= and connection strings.
Step 2: Change the password now

Create a new database password in the hosting panel and update the app. Assume the old one is exposed.
Step 3: Move values out

Store them in a .env file or the host's environment variable settings, outside the public web root.
Step 4: Read them in code

Use getenv() in PHP, process.env in Node or os.environ in Python.
Step 5: Ignore the file

Add .env to .gitignore and commit an example file with fake values.
Step 6: Clean the history

If the repo is public or shared, remove the secret from history with git filter-repo and force push.
Step 7: Limit the database user

Give the app user only the permissions it needs.
Still stuck?
If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.
Related guides
- WordPress User Can't See Posts They Created: Roles and Permissions
- WordPress Site Health Warnings: What To Fix First
- WordPress: Create a New Admin User via Database When Locked Out
- WordPress Automatic Updates: Enable, Disable and Safe Settings