Home > Backend Development > PHP Tutorial > PHP连接sqlserver2008,如何连接指定ip地址上的数据库

PHP连接sqlserver2008,如何连接指定ip地址上的数据库

WBOY
Release: 2016-06-13 12:02:41
Original
1168 people have browsed it

PHP连接sqlserver2008,怎么连接指定ip地址上的数据库

$serverName = "(local)"; //数据库服务器地址<br />$uid = "sa"; //数据库用户名<br />$pwd = "password123"; //数据库密码<br />$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"test");<br />$conn = sqlsrv_connect( $serverName, $connectionInfo);<br />if( $conn == false)<br />{<br />    echo "连接失败!";<br />    die( print_r( sqlsrv_errors(), true));<br />}<br />if($conn){<br />echo "连接成功";<br />}
Copy after login

连接成功了,但是怎么把local改成127.0.0.1这样的
------解决方案--------------------
直接换成ip地址
------解决方案--------------------
$serverName = "ip地址";

$serverName = "计算机名";
如果服务器上有多个实例,还需要有实例名

远程连接还需开启远程连接服务
由于 sqlserver 2000 的默认远程连接,导致了 SQL攻击 的盛行。
所以现在都学乖了,不经繁琐的远程连接授权,是无法连接的

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template