Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install unixODBC >= 2.3.1 on Linux Redhat/CentOS for msodbcsql17

I try to install msodbcsql17 on AWS EC2 with CentOS/RedHat (Linux).

These are the steps, I have followed, from Microsoft (LINK):

sudo su

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#RedHat Enterprise Server 6
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RedHat Enterprise Server 7
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo

exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel

The instruction work until the installation of msodbcsql17. I get the following error message:

Error: Package: msodbcsql17 (packages-microsoft-com-prod)
           Requires: unixODBC >= 2.3.1
           Available: unixODBC-2.2.14-14.7.amzn1.i686 (amzn-main)
               unixODBC = 2.2.14-14.7.amzn1

I think the problem is, that the maximum available version of unixODBC is less then 2.3.1, but how can I install msodbcsql17, to connect with Microsoft?

like image 609
Sean Stayns Avatar asked May 17 '18 21:05

Sean Stayns


People also ask

How to check Microsoft ODBC Driver version in Linux?

To verify that the Microsoft ODBC driver on Linux was registered successfully, execute the following command: odbcinst -q -d -n "ODBC Driver 11 for SQL Server" .

What is unixODBC devel?

unixODBC-devel is Development files for programs which will use the unixODBC library Development files for programs which will use the unixODBC library.

How do I install The unixODBC driver?

The driver installation updates odbcinst.ini. odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager. To discover the location of odbcinst.ini on your computer, execute the following command: odbc_config --odbcinstini. Before you install the driver, execute the following command: ./install.sh verify.

What is the msodbcsql-11 installation file for Red Hat Linux?

These instructions refer to msodbcsql-11.0.2270.0.tar.gz, which is installation file for Red Hat Linux. If you are installing the Preview for SUSE Linux, the file name is msodbcsql-11.0.2260.0.tar.gz. Make sure that you have root permission.

How do I install the msodbcsql driver on Linux?

To install the driver: Make sure that you have root permission. Change to the directory where the download placed the file msodbcsql-11.0.2270.0.tar.gz. Make sure that you have the *.tar.gz file that matches your version of Linux. Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called install.sh.

What is the latest version of unixODBC for Amazon Linux?

But the updated/latest unixODBC package available for amazon is unixODBC-2.2.14. I need some help to install Microsoft Drivers for PHP on Amazon Linux so that I can use SqlsrvPHP functions to connect SQL server.


1 Answers

After a long time of research, I have figured out a solution:

  1. Download the unixODBC >= 2.3.1 from any source, as rpm (Example source)
  2. Download the msodbcsql17 and mssql-tool as rpm from Microsoft (Link to Repo) (msodbcsql17-17.1.0.1-1.x86_64.rpm and mssql-tools-17.1.0.1-1.x86_64.rpm in my case)
  3. Transfer the files via ftp (like FileZilla) to the EC2 instance
  4. Use EC2 terminal and go to the directory of the uploaded files
  5. Enter sudo rpm -i unixODBC-2.3.1-11.el7.x86_64.rpm to install the necessary version (Perhaps, you have to change the version number to the version number of the uploaded file)
  6. Enter sudo rpm -i msodbcsql17-17.1.0.1-1.x86_64.rpm
  7. Enter sudo rpm -i mssql-tools-17.1.0.1-1.x86_64.rpm

  8. Follow the rest of the Microsoft instruction, like in your question.

  9. Now you should be able to use ODBC for example with pyodbc in python.

Instead of rpm -i, you can use yum install as well


UPDATE: Please take a look at the comment from @KnudLarsen!

like image 55
Sean Stayns Avatar answered Sep 18 '22 17:09

Sean Stayns