ITPub博客

首页 > 数据库 > SQL Server > 远程访问数据库MS SQL SERVER 2008及Mysql数据库

远程访问数据库MS SQL SERVER 2008及Mysql数据库

SQL Server 作者:lovekix 时间:2013-12-13 12:30:46 0 删除 编辑

环境:win7(做办事器装有MSSQL2008,IP:192.168.1.119,WAMP(Apache2.2.17、PHP5.3.3、Mysql5.5.8)),XP(接见数据库192.168.1.130,WAMP(Apache2.2.17、PHP5.3.3、Mysql5.5.8))

XP接见Mysql(win7)

testmysql.php(XP->...www)

$link = mysql_connect("192.168.1.119","root","");
if (!$link) {
 die("Could not connect to MySQL: " . mysql_error());
}
echo "Connection OK"; mysql_close($link);
?>

蜕化
Warning: mysql_connect() [function.mysql-connect]: Host "2012-20130526NP" is not allowed to connect to this MySQL server in C:wampwww estmysql.php on line 2
Could not connect to MySQL: Host "2012-20130526NP" is not allowed to connect to this MySQL server

打点

mysql>use mysql;

mysql>update user set host =’%"where user =’root’;

mysql>flush privileges;

以上的代码没有表白......

XP接见sqlsrv(win7)

testsqlsrv.php

//phpinfo();
$serverName="192.168.1.119,1433";//(local)
echo $serverName;
$uid="sa";
$pwd="1111";
$connectInfo=array("UID"=>$uid,"PWD"=>$pwd,"Database"=>"ReportServer");
$conn=sqlsrv_connect($serverName,$connectInfo);
if (!$conn) {
    die("Could not connect to SqlServer". print_r( sqlsrv_errors(), true));
}
echo "Connection OK";sqlsrv_close($conn);
?>

先将此文件放正在WIN7->...www下运止,先将192.168.1.119,1433改成(local)

蜕化

Fatal error: Call to undefined function sqlsrv_connect() in C:wampwwwsqlsrv-test.php on line 8

打点

php5.3版本以上没有正在支撑php_mssql.dll模块对sqlsrv接见,没有过MS供给给大家了http://www.microsoft.com/en-us/download/details.aspx?id=20098>

下载来当前解压(先新建一个文件夹解压正在那里),那里表白一下那些文件VC6放正在Apache下的,VC9放正在IIS下的,ts代表有线程安齐,nts代表无线程安齐

借有那儿那边要下载SQLSRV20.EXE or SQLSRV30.EXE

阿谁扩展包对电脑的操作系统有要求,对应的系统行使对应的版本。
3.0  所支撑的操作系统
Windows Server 2008 R2 SP1
Windows Vista SP2
Windows Server 2008 SP2
Windows 7 SP1
2.0 所支撑的操作系统
Windows Server 2003 Service Pack 1
Windows XP Service Pack 3
Windows Vista Service Pack 1 or later
Windows Server 2008
Windows Server 2008 R2
Windows 7

本人用的是SQLSRV20.EXE->php_pdo_sqlsrv_53_ts_vc6.dll 和 php_sqlsrv_53_ts_vc6.dll

挨开php.ini文件,正在extension=php_mysql.dll 下面一止增减

extension=php_pdo_sqlsrv_53_ts_vc6.dll
extension=php_sqlsrv_53_ts_vc6.dll

重启

=================================================

再将此文件放正在XP->...www下,正在运止前先确保MSSQL2008长途开启,阿谁网上有教程

若是那样揭示以下弊端

Unable to connect.
array(2) { [0]=> array(6) { [0]=> string(5) “IMSSP” ["SQLSTATE"]=>string(5) “IMSSP” [1]=> int(-49) ["code"]=> int(-49) [2]=> string(390)“This extension requires either the Microsoft SQL Server 2008 NativeClient (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712″> ["message"]=> string (390) “This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712″> } [1]=> array(6) {[0]=> string(5) “IM002″ ["SQLSTATE"]=> string(5) “IM002″ [1]=> int(0)["code"]=> int(0) [2]=> string(71)

打点

以上是说没安装驱动

点击http://msdn.microsoft.com/en-us/library/cc296170.aspx>阿谁链接 进入下载驱

动程序包便可以或许了,X86 Package(sqlncli.msi) 。安装的时辰有可以或许某些软件会影响到安装,导致安装掉败,

倡议您关掉落没用的程序。


<!-- 正文结束 -->

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21894119/viewspace-1114518/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-06-14