If you’re working with a Red Hat Enterprise Linux (RHEL) server and need to install ODBC Driver 17 for SQL Server to establish a connection, follow the simple steps outlined below. This guide will also walk you through the installation of the unixODBC-devel package, which is often required for development purposes.
Prerequisites
- RHEL 7 or 8 system.
- Root or sudo privileges.
1. Download Microsoft Repository Configuration Package
Before installing the Microsoft ODBC Driver, we need to configure the Microsoft repository on your system. The following command will download the Microsoft repository configuration package based on your RHEL version.
curl -sSL -O https://packages.microsoft.com/config/rhel/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2 | cut -d '.' -f 1)/packages-microsoft-prod.rpm
This command retrieves the appropriate repository configuration for your version of RHEL.
2. Install the Repository Configuration Package
Once the configuration file is downloaded, install the package to configure the Microsoft repository on your RHEL server:
sudo yum install packages-microsoft-prod.rpm
After installation, it’s a good practice to delete the downloaded .rpm file to keep your server clean (optional):
rm packages-microsoft-prod.rpm
3. Remove Potential Conflicting Packages
Sometimes, certain packages like unixODBC-utf16 can conflict with the installation of the necessary ODBC driver. To avoid these conflicts, you can remove the potentially problematic packages with the following command:
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
4. Install Microsoft ODBC Driver 17 for SQL Server
Now that your system is properly configured, you can install the ODBC Driver 17 for SQL Server using the following command:
sudo ACCEPT_EULA=Y yum install -y msodbcsql17
The ACCEPT_EULA=Y flag ensures that you accept the Microsoft End User License Agreement (EULA) before installation proceeds.
5. Install unixODBC-devel Package
For development purposes, if you need to access the Unix ODBC development headers, you can install the unixODBC-devel package with the following command:
sudo yum install -y unixODBC-devel
This package provides development libraries and headers for working with ODBC data sources.
6. Optional: Install SQLCMD and BCP Tools
If you require additional tools such as sqlcmd (SQL command-line tool) and bcp (bulk copy utility) for interacting with your SQL Server instance, you can install them by running:
sudo ACCEPT_EULA=Y yum install -y mssql-tools
Once the tools are installed, you can add their binaries to your system’s PATH by running:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Conclusion
You’ve now successfully configured your RHEL server with Microsoft ODBC Driver 17 (msodbcsql17) for SQL Server and the unixODBC-devel package, and optionally installed the mssql-tools and development headers. With these tools in place, you can begin working with SQL Server databases on your Linux machine, using both the command-line tools and ODBC connections in your development projects.
If you need assistance to Install Microsoft ODBC Driver 17 (msodbcsql17) for SQL Server and unixODBC-devel on RHEL, feel free to contact us.