Can't Install FreeTDS via Yum Package Manager
As adopted from Benny Hill's comment above, this is what got freetds installed for me:
rpm -ivh ftp://fr2.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
cd /etc/yum.repos.d/
wget http://rpms.famillecollet.com/enterprise/remi.repo
yum install freetds
yum install freetds-devel
yum install --enablerepo=remi php-mssql
Adopted from https://gist.github.com/shf/2052432
Missing libtdsodbc.so in freetds-dev - MSSQL on Ubuntu
I ended up solving it with the help of this listserv post:
http://mailman.unixodbc.org/pipermail/unixodbc-support/2008-November/001842.html
Except:
Driver = TDS
Should be:
Driver = FreeTDS
That weird 64-bit driver I had to manually find was also relevant, and ignoring freetds.conf was the way to go.
Fun stuff.
Should one use FreeTDS driver instead of MS SQL Driver for compatibility between older PHP and newer SQL Servers?
You said
The reason why I asked that was because of Microsoft official documentation which says I cannot connect to newer versions of SQL Server if my PHP version is below 7.*.
and
Is this php 5.4 connection really supposed to work with newest SQL
Server despite the official Microsoft docs say it should not?
...but actually, the Microsoft documentation you're talking about doesn't say you can't connect to SQL Server from PHP 5.4.
They said you can't (or at least you are not supported to) do that by using the Microsoft Drivers for PHP for SQL Server - which is the specific product that documentation is talking about.
FreeTDS is a different driver. By replacing the driver, you've replaced the thing which Microsoft is saying you shouldn't use. AFAIK Microsoft have no involvement with FreeTDS, so what they support, and what their driver works with, is entirely up to them.
pdo dblib on centos 6.x
The easy way to achieve that:
- Enable EPEL repository
- Install
php-mssql
. That will installunixODBC
andfreetds
, too.
# yum install php-mssql
Then, you can connect from PHP + PDO (using the dblib driver) from CentOS to your MSSQL server
$dsn = "dblib:host=<host>;dbname=<dbname>";
$user = <user>;
$password = <password>;
$db = new PDO($dsn, $user, $password);
Dockerfile example, but should also work with any CentOS6+ and PHP 7.0:
FROM centos:centos7
RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm\
# We include PHP 7 from REMI since it's not in EPEL.
http://rpms.remirepo.net/enterprise/remi-release-7.rpm\
# This will help verify packages and so you will see fewer errors(red) in the build output.
&& rpm --import \
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7\
/etc/pki/rpm-gpg/RPM-GPG-KEY-remi\
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7\
# Spedify which version of PHP 7 to install here
&& yum-config-manager --enable remi,remi-php70\
&& yum -y install php-mssql
Related Topics
Get a Nanosecond-Precise Atime, Mtime, Ctime Fields for File (Stat)
How to Know Which Device Is Connected in Which /Dev/Ttyusb Port
Command to Insert Lines Before First Match
How to Keep Executable Code in Memory Even Under Memory Pressure? in Linux
Undefined Reference to Symbol 'Dlsym@@Glibc_2.4'
Bumping Version Numbers for New Releases in Associated Files (Documentation)
Checkpoint/Restart Using Core Dump in Linux
How to Read Data from Excel Sheet in Linux Using Shell Script
How to Use Cx_Freeze in Linux to Create a Package to Be Used in Windows
Command for Finding Process Using Too Much Cpu
Cannot Clone Repository: Fatal: R Any Gitolite-Admin Gitolite Denied by Fallthru
Is a Core Dump Executable by Itself
How to Overcome an Incompatibility Between the Ksh on Linux VS. That Installed on Aix/Solaris/Hpux
How to Use Watir to Scrape Data from a Website on a Linux Server Without Monitor