Score:0

Not able to install drivers for sql server on CENTOS

fr flag

I am new at Linux OS but successfully installed apache, PHPMyAdmin, and MariaDB.

All works fine, but I have an issue and am not able to resolve it. My issue is establishing a connection to the SQL Express server which runs on WIndows machine on the same network. My script to sql ex

I was working with Windows environment with XAMPP installed I had no issues drivers for SQL express server were working.

When I do php -v in Centos, I get PHP 7.4.21 (cli) version installed. I was trying to install sqlsrv pdo drivers but have no luck. It tells me it is installed but i get issue when trying to establish a connection

Not sure how I can solve the issue. Attaching issue img error in establishing connection

Connection string I use

$serverName = "Machine\SQLEXPRESS"; //serverName\instanceName
$connectionInfo = array( "Database"=>"TestDB", "UID"=>"sa", "PWD"=>"password" , "CharacterSet" => "UTF-8");
$con = sqlsrv_connect( $serverName, $connectionInfo);

if( $con ) {
  echo "It works";
}else{
  echo "Connection could not be established.";
  die( print_r( sqlsrv_errors(), true));
}
Michael Hampton avatar
cz flag
This is not a driver issue. It is most likely a wrong connection information.
dcron avatar
fr flag
@MichaelHampton I am using the same connection as I used on xampp environment to connect to Windows Server Machine with SQL. Updated answer with the connection string. Is there anything you suggest I can do
Michael Hampton avatar
cz flag
Is the machine actually up and running?
dcron avatar
fr flag
Yes it is always up and running
Michael Hampton avatar
cz flag
OK, then go and do what the error message said to do.
dcron avatar
fr flag
Is there anyhting on Linux side that has to be done? This sever was working when I had xampp on win 10. This connection to sql server worked. Now, after I moved to Centos it doesnt work :(
Michael Hampton avatar
cz flag
Have you read the error message and done what it suggests?
dcron avatar
fr flag
Yes I did, server allows remote connection.
sridhar pandurangiah avatar
aq flag
Have you checked if the ports are open on the windows machine?
Score:0
jp flag

sqlsrv pdo isn't for MariaDB. for MariaDB you need to install php-mysql package. in Debian it's may be called php-mysql, or php7.4-mysql. in Centos it should be something like that also. try to find it by

yum list php*mysql*

command. if you would get success with that - try to install it with

yum install <packagename>

command, where is name of package you have found. P. S.: if you have some kind of error messages, you should post it by text, not by image like you did.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.