| | |
Securing my database access password
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
I hate having the password for my database out in the open. Anyone who gets a look at my code has access to the password. What can I do to secure it so my PHP scripts can access it but it's harder to find?
I thought about storing it in a file, but if you've got read access to the file you've got read access to the password. Encryption is the next thing I thought of, but my script would have to do the decryption. Once you have that info, what's to keep you from using it?
How can I keep it safe and still use it?
I thought about storing it in a file, but if you've got read access to the file you've got read access to the password. Encryption is the next thing I thought of, but my script would have to do the decryption. Once you have that info, what's to keep you from using it?
How can I keep it safe and still use it?
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
•
•
Originally Posted by Puckdropper
I hate having the password for my database out in the open. Anyone who gets a look at my code has access to the password. What can I do to secure it so my PHP scripts can access it but it's harder to find?
I thought about storing it in a file, but if you've got read access to the file you've got read access to the password. Encryption is the next thing I thought of, but my script would have to do the decryption. Once you have that info, what's to keep you from using it?
How can I keep it safe and still use it?
dynastyCODERS#1 when it comes to Programming Tutorials, Database designs and discussions, Operating Systems, you name it, check us out and drop us a line to tell us your opinions on any and everything in mind!;)
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
They're for the whole thing. I thought about using a hash that's so long it'd be difficult for a human to copy, but that still doesn't prevent machine copying.
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Try this. You can always use a file that is stored outside to the Web site tree on your server. The file can contain the entire command to open the database, including the database name and password. You then include that file in your Web script using the server path (not the Web site path). Files stored outsite of the Web site tree are not accessible via the Internet.
Heres an example of a call to a file above the Web site tree on a server:
require_once ('/home/mysiteaccountname/temp/DB01.php');
Here is what is in DB01.php:
mysql_select_db('myDatabse', mysql_connect('localhost','myUserName','myPassword')) or die(mysql_error() );
Files that are stored outside of the Web space cannot be read from the Internet, but they can be read from a script within the site's Web space. This means your PHP program can read it, but someone using your site should not be able to get to it. All the important info about your database is out of the reach of the bad guys.
If you want to add an additional level of security, them encrypt the password as well.
Heres an example of a call to a file above the Web site tree on a server:
require_once ('/home/mysiteaccountname/temp/DB01.php');
Here is what is in DB01.php:
mysql_select_db('myDatabse', mysql_connect('localhost','myUserName','myPassword')) or die(mysql_error() );
Files that are stored outside of the Web space cannot be read from the Internet, but they can be read from a script within the site's Web space. This means your PHP program can read it, but someone using your site should not be able to get to it. All the important info about your database is out of the reach of the bad guys.
If you want to add an additional level of security, them encrypt the password as well.
![]() |
Similar Threads
- Help me in username and password validation through accessing the database (ASP.NET)
- Connecting password protected MS Access database from C# (C#)
- MS Access password (MS Access and FileMaker Pro)
- need your help with database access (Visual Basic 4 / 5 / 6)
- Database access with Java platform (MS Access and FileMaker Pro)
- database access is getting slow day by day (MySQL)
Other Threads in the PHP Forum
- Previous Thread: PHP with MS access ?
- Next Thread: Mambo Administrator Problems - Page Not Found
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





