Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

585
Views
Is there any specific setting for connecting to SQL Server through PHP on Linux CentOS 7

I have already done this through Windows machine but getting error on Linux. I have been searching for the similar issues and implementing all I could get, but still no luck.

I am trying to connect SQL server on following environment: Microsoft SQL Server 2016, Linux Centos 7.9.2009, PHP 7.3.29, ODBC Driver 13 and 17

I have already install and enable the PDO_ODBC and pdo_sqlsrv, confirmed through phpinfo.

Below is my connection string:

$conn = new PDO("odbc:Driver={ODBC Driver 13 for SQL Server};SERVER=192.168.99.237;Port:24115;Database=dbname;Uid=username;Pwd=password;")

also tried

$conn = new PDO("odbc:Driver={ODBC Driver 13 for SQL Server};SERVER=192.168.99.237,24115;Database=dbname;", "username", "password")

and the error is

SQLSTATE[HYT00] SQLDriverConnect: 0 [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired

Updated code and findings:

I am able to connect via cli:

isql MSSQL username password
tsql -S MSSQL -U 'username' -P 'password'
osql -S mssql -U username -P password

While trying through below PHP connection string, getting 'could not find driver'

new PDO("dblib:host=mssql;dbname=database", "username", "password");
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!