A few things would be important here:
-
Granted, I shouldn't be able to get your production database password, but even if I did, I shouldn't be able to access it because it should be accessible only internally on the network to other servers. Firewalls should prevent me from being able to access it directly. Beyond that, at least in MySQL, I can allow access to specific usernames from specific IPs or localhost, so that would prevent me from logging in even if I had the full and correct credentials.
-
If you're talking about the broader, non-database use case: if your company is large enough that have concerns about developer access to production code and you have systems and protections and permissions in place to prevent access to production from developers, that means you're big enough to have and use code reviews. Code reviews catch and prevent these kinds of problems, intentional or accidental, from seeping into your codebase.
-
You might consider doing some kind of basic static analysis of your code in your build system; it can be a sophisticated library, or it can even be as simple as grepping for instances of "dd(" or "die(" or "exit" or any of a number of other things. I wouldn't necesarrily recommend the grep approach, but nevertheless it might be something where you currently have nothing.
Don't know if any or all of these answered your questions or concerns, but hopefully it gets you on the right track.