How to secure database passwords in PHP?

后端 未结 16 1529
闹比i
闹比i 2020-11-21 22:41

When a PHP application makes a database connection it of course generally needs to pass a login and password. If I\'m using a single, minimum-permission login for my applica

16条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-21 23:15

    if it is possible to create the database connection in the same file where the credentials are stored. Inline the credentials in the connect statement.

    mysql_connect("localhost", "me", "mypass");
    

    Otherwise it is best to unset the credentials after the connect statement, because credentials that are not in memory, can't be read from memory ;)

    include("/outside-webroot/db_settings.php");  
    mysql_connect("localhost", $db_user, $db_pass);  
    unset ($db_user, $db_pass);  
    

提交回复
热议问题