[英]Can't connect to localhost SQL server 2012 with php
Hi I have a big problem with php connection to my local database. 嗨,我对本地数据库的php连接有很大的疑问。
I'm running: Windows Server 2008 sp 1. SQL server 2012. My SQL server name: LRE-XP-VS2003\\SQLEXPRESS. 我正在运行:Windows Server 2008 sp 1. SQL Server2012。我的SQL Server名称:LRE-XP-VS2003 \\ SQLEXPRESS。 (status is running) (状态正在运行)
This is how I'm trying to connect 这就是我尝试连接的方式
$server = 'localhost'; //or 127.0.0.1
$login = 'sa';
$passwd = 'my_passwd';
$database = 'ms4033';
$port = '49717';
$con = mysqli_connect ( $server , $login, $passwd, $database, $port );
if (!$con) {
die("Connection error: " . mysqli_connect_errno());
}
Result I get is spinning the loading button in browser and after long time "Internal Server Error - The FastCGI process exceeded configured activity timeout" 我得到的结果是在浏览器中旋转加载按钮,并且经过很长时间“内部服务器错误-FastCGI进程超出了配置的活动超时”
For the port number I checked in HKEY_LOCAL_MACHINE
and also directly in database 对于端口号,我在HKEY_LOCAL_MACHINE
检查了,也直接在数据库中检查了
USE master
GO
XP_READERRORLOG 0, 1, N'Server is listening'
GO
and in SQL server Configuration manager too. 以及在SQL Server配置管理器中。 Without port number I get "No connection could be made because the target machine actively refused it" or "Connection error: 2002" 没有端口号,我将收到“由于目标计算机主动拒绝连接而无法建立连接”或“连接错误:2002”
I tried diseable my Firewall and it did not help. 我尝试禁用防火墙,但没有帮助。
I'm running asp .net too and paradoxically the connection is working properly with this: 我也正在运行asp .net,自相矛盾的是,此连接工作正常:
<add key="connectionString" value="server=LRE-XP-VS2003\SQLEXPRESS;database=ms4033;packet size=4096;user id=sa;password=my_passw" />
Am I missing something? 我想念什么吗?
And what's difference between $server = 'localhost';
和$server = 'localhost';
之间有什么区别$server = 'localhost';
or $server = 'LRE-XP-VS2003\\SQLEXPRESS';
或$server = 'LRE-XP-VS2003\\SQLEXPRESS';
? ?
Thanks a lot. 非常感谢。
Check this article. 检查此文章。 You need to use MS SQL connection, not the MYSQL 您需要使用MS SQL连接,而不是MYSQL
<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'KALLESPC\SQLEXPRESS';
// Connect to MSSQL
$link = mssql_connect($server, 'sa', 'phpfi');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
?>*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.