[英]Using IP address instead of 'localhost' as hostname in mysqli connection
I am perhaps being a bit overly cautious asking this and apologies if it has been but I want to be as secure as possible. 我可能会有点过分审慎,询问是否已经道歉,但我想尽可能地保持安全。 Is it just as secure to use my hosting accounts IP address instead of localhost when I connect to the database via my mysqli connection below?
通过下面的mysqli连接连接到数据库时,使用托管帐户的IP地址而不是本地主机是否同样安全? Would the speed of connection be dramatically affected at all?
连接速度会受到根本影响吗?
$hostname = "localhost";
$database = "wwwcapco_crm";
$username = "wwwcapco_user";
$password = "cKUsaf#&^0";
$connect = new MySQLi($hostname, $username, $password, $database);
if ($connect->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli- >connect_errno . ") " . $mysqli->connect_error; }
The main reason I ask is because at the moment I am exporting my live website database and importing it into my local website testing enviroment (xampp). 我问的主要原因是因为目前我正在导出实时网站数据库并将其导入到本地网站测试环境(xampp)中。 This takes ages and I just thought it may be a better idea to connect directly to the live database.
这花了很长时间,我只是认为直接连接到实时数据库可能是一个更好的主意。
Thanks 谢谢
Is it just as secure to use my hosting accounts IP address instead of localhost when I connect to the database via my mysqli connection below?
通过下面的mysqli连接连接到数据库时,使用托管帐户的IP地址而不是本地主机是否同样安全?
No. See the documentation : 否。请参阅文档 :
All other information is transferred as text, and can be read by anyone who is able to watch the connection.
所有其他信息均以文本形式传输,任何能够查看连接的人都可以阅读。 If the connection between the client and the server goes through an untrusted network
如果客户端和服务器之间的连接通过不受信任的网络
Would the speed of connection be dramatically affected at all?
连接速度会受到根本影响吗?
Since you are getting the data from a computer at a remote site instead of locally — yes, it will. 由于您是从远程站点而非本地计算机上获取数据的,所以可以。
local website testing enviroment (xampp).
本地网站测试环境(xampp)。 This takes ages and I just thought it may be a better idea to connect directly to the live database
这花了很长时间,我只是认为直接连接到实时数据库可能是一个更好的主意
Risking your live data by exposing it to your test code is a very bad idea. 通过将实时数据暴露于测试代码中来冒风险,这是一个非常糟糕的主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.