在哪里是最安全的地方为PHP提供MySQL连接详细信息 [英] Where is the most secure place to put MySQL connection details for PHP

查看:206
本文介绍了在哪里是最安全的地方为PHP提供MySQL连接详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当通过PHP脚本连接时,在哪里可以放置MySQL数据库连接的详细信息?

  $ connection = mysql_connect ($ hostname,$ username,$ password); 
if(!$ connection){die('Could not connect:'。mysql_error());}
mysql_select_db($ database,$ connection);

我知道将它们直接放在查询数据库的脚本中并不是一个好主意。但是,有人说应该将连接详细信息放在单独的PHP脚本中,并包含要连接的脚本。



是否有更安全的地方放置连接详细信息?

解决方案

通常的做法是将它们放在单独的文件中,并放在web根目录之外。有关详情,请参见 此答案 。 / p>

Where is the most secure place to put MySQL database connection details when connecting via a PHP script?

$connection = mysql_connect($hostname, $username, $password);
if (!$connection) {die('Could not connect: ' . mysql_error());}
mysql_select_db($database, $connection);

I know it's not a good idea to put them directly in the script that is querying the database. However, some say that you should put the connection details in a separate PHP script and include that script to connect.

Is there a more secure place to put the connection details?

解决方案

The usual practice is to put them into a separate file, and put that outside the web root. See this answer for details.

这篇关于在哪里是最安全的地方为PHP提供MySQL连接详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆