Re: How to hide MySQL password in connection string in PHP script?
| From: | ceo at l-i-e dot com | Date: | Tue, 02 Dec 2008 15:11:46 +0000 |
| Subject: | Re: How to hide MySQL password in connection string in PHP script? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-283990@lists.php.net to get a copy of this message | ||
On a shared server, you rarely can really protect your MySQL user/pass from other users on the same
server.
The problem is that your PHP process is probably an Apache module, and you probably don't have
your own separate pool of Apache User processes.
So, by definition, if YOUR script can read the .php file and load it and get the user/pass to use
them, then ANY .php file can load the file and get the user/pass to abuse them.
You have to weigh this risk with the value/secrecy/privacy of the data, and decide what to do.
You might have to move to a dedicated server. You might not.
You might just add a barrier for the absolutely crucial fields of 2-way encrypting them in PHP. Of
course, the bad person can then read your other .php file to find the 2-way de-cryption, but
it's more steps for them to go through, and if the data isn't THAT interesting, they
won't.
You would NOT want to do this for:
credit card info (which probably doesn't need storing anyway)
SSN
medical info
But you might not care all THAT much for yet another shopping cart or a blog etc.
Keep backups though, just in case a rogue user does mess you up!