当前位置:网站首页>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
边栏推荐
- B+ tree (4) joint index -- MySQL from entry to proficiency (16)
- Precautions for triggering pytest.main() from other files
- Segmentation fault (core dumped)
- Seven steps to copywriting script ---- document team collaborative management
- Code cloud, which officially supports the pages function, can deploy static pages
- Basic sentence structure of English ----- origin
- 《Kotlin系列》之MVVM架构封装(kotlin+mvvm)
- 重押海外:阿里、京东、顺丰再拼“内力”
- The use of asynchronous thread pool in development
- B+ tree index uses (7) matching column prefix, matching value range (19)
猜你喜欢

【着色器实现Overlay重新覆盖变装效果_Shader效果第九篇】

历时15年、拥有5亿用户的飞信,彻底死了

Re bet overseas: Alibaba, jd.com and SF again fight for "internal power"

Implementation of SAP ABAP daemon

Pytoch learning notes (I) installation and use of common functions
![[oauth2] VII. Wechat oauth2 authorized login](/img/1a/3f2b9fc57759a1fa3fda1451492e5c.png)
[oauth2] VII. Wechat oauth2 authorized login

Solve the problem that the remote host cannot connect to the MySQL database

Seven steps to copywriting script ---- document team collaborative management

Unicode文件解析方法及存在问题

Pytoch learning notes (III) use, modification, training (cpu/gpu) and verification of the model
随机推荐
SuperMap iclient for leaflet loads Gauss Kruger projection three-dimensional zonation CGCS2000 geodetic coordinate system WMTs service
Oom caused by improper use of multithreading
【黑马早报】字节旗下多款APP下架;三只松鼠脱氧剂泄露致孕妇误食;CBA公司向B站索赔4.06亿;马斯克否认与谷歌创始人妻子有婚外情...
多线程使用不当导致的 OOM
[dark horse morning post] many apps under bytek have been taken off the shelves; The leakage of deoxidizer in three squirrels caused pregnant women to eat by mistake; CBA claimed 406million yuan from
Pytoch learning notes (III) use, modification, training (cpu/gpu) and verification of the model
官宣!艾德韦宣集团与百度希壤达成深度共创合作
历时15年、拥有5亿用户的飞信,彻底死了
《Kotlin系列》之MVVM架构封装(kotlin+mvvm)
Multi objective optimization series 1 --- explanation of non dominated sorting function of NSGA2
TDSQL-C Serverless:助力初创企业实现降本增效
Huawei computer test ~ offset realizes string encryption
B+ tree index uses (7) matching column prefix, matching value range (19)
Unicode文件解析方法及存在问题
Convert the array in JSON file to struct
We were tossed all night by a Kong performance bug
421. Maximum XOR value of two numbers in the array
Analysis on the current situation and optimization strategy of customer experience management in banking industry
带你熟悉云网络的“电话簿”:DNS
Frisbee, 2022 "black red" top stream