当前位置:网站首页>php使用sqlserver
php使用sqlserver
2022-07-26 13:44:00 【集合鹅鹅鹅鹅】
1、安装ODBC程序
官方下载地址:Download ODBC Driver for SQL Server - ODBC Driver for SQL Server | Microsoft Docs
2、下载sqlsrv扩展文件
官方下载地址:Download the Microsoft Drivers for PHP for SQL Server - PHP drivers for SQL Server | Microsoft Docs
3、把扩展文件对应的版本移动到PHP对应的目录下的ext目录;
4、更改PHP的配置文件,添加扩展,(以php7.4为例)
extension=php_pdo_sqlsrv_74_ts_x64
extension=php_sqlsrv_74_ts_x64
5、重启apache或nginx服务
注意看官方文档的发行说明,即使用sqlserver的php驱动与操作系统和php版本相关要求
https://docs.microsoft.com/zh-cn/sql/connect/php/release-notes-php-sql-driver?view=sql-server-ver16#previous-releases
当你没有安装ODBC程序或没有配置好sqlsrv文件,会返回微软官方下载ODBC的链接或提示sqlsrv函数未定义
上面两个东西弄好后可能遇到报错:
[08001] [Microsoft][SQL Server Native Client 11.0]TCP 提供程序:由于目标计算机积极拒绝,无法连接。\r\n (10061) (SQLDriverConnect); [08001]
[Microsoft][SQL Server Native Client 11.0]登录超时已过期 (0); [08001]
[Microsoft][SQL Server Native Client 11.0]无效的连接字符串属性 (0); [08001]
[Microsoft][SQL Server Native Client 11.0]与 SQL Server 建立连接时发生了与网络相关的或特定于实例的错误。找不到或无法访问服务器。请检查实例名称是否正确以及 SQL Server 是否配置为允许远程连接。
这个不要担心,只是用户名密码之类的值填写有问题
另外也大概率是端口号问题
由于sqlserver网络配置的tcp/ip中默认端口是1433
再看你代码中的连接端口是不是1433(127.0.1.1,1433),如果不是改一下端口号
另外还有可能有些端口号没有开放。
参考链接:
https://blog.csdn.net/u012887346/article/details/124768262
https://blog.csdn.net/u010423663/article/details/125464776
https://docs.microsoft.com/zh-cn/sql/connect/php/release-notes-php-sql-driver?view=sql-server-ver16#previous-releases
边栏推荐
- Multi objective optimization series 1 --- explanation of non dominated sorting function of NSGA2
- 异步线程池在开发中的使用
- 官宣!艾德韦宣集团与百度希壤达成深度共创合作
- 【开源之美】nanomsg(2) :req/rep 模式
- Team research and development from ants' foraging process (Reprint)
- 如何构建以客户为中心的产品蓝图:来自首席技术官的建议
- 重押海外:阿里、京东、顺丰再拼“内力”
- JS get the current time, time and timestamp conversion
- 2022年,我们只用一个月就“送走”了这么多互联网产品
- Seven steps to copywriting script ---- document team collaborative management
猜你喜欢

2022年,我们只用一个月就“送走”了这么多互联网产品

Implementation of SAP ABAP daemon

JSON data transfer parameters & date type parameter transfer

云智技术论坛工业专场 明天见!

Zhou Wei: look for non consensual investment opportunities to accompany the founding team that delays satisfaction

【黑马早报】字节旗下多款APP下架;三只松鼠脱氧剂泄露致孕妇误食;CBA公司向B站索赔4.06亿;马斯克否认与谷歌创始人妻子有婚外情...

Win11+VS2019配置YOLOX

JSON数据传递参数&日期型参数传递

.net6 encounter with the League of heroes - create a game assistant according to the official LCU API

Official announcement! Edweisen group and Baidu xirang reached a deep co creation cooperation
随机推荐
Codeforces Round #810 (Div. 2)【比赛记录】
In 2022, we "sent away" so many Internet products in only one month
【Oauth2】五、OAuth2LoginAuthenticationFilter
JS get the current time, time and timestamp conversion
[beauty of open source] nanomsg (2): req/rep mode
JS object assignment problem
Brief introduction of reflection mechanism
.NET WebAPI 使用 GroupName 对 Controller 分组呈现 Swagger UI
「中高级试题」:MVCC实现原理是什么?
404 pages and routing hooks
B+ tree index use (8) sorting use and precautions (20)
JSON data returned by controller
B+ tree index uses (7) matching column prefix, matching value range (19)
B+ tree index use (6) leftmost principle -- MySQL from entry to proficiency (18)
Convert the array in JSON file to struct
Control the probability of random winning [C | random]
Pytorch学习笔记(二)神经网络的使用
【黑马早报】字节旗下多款APP下架;三只松鼠脱氧剂泄露致孕妇误食;CBA公司向B站索赔4.06亿;马斯克否认与谷歌创始人妻子有婚外情...
Analysis on the current situation and optimization strategy of customer experience management in banking industry
[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve