Skip to content

Can't install MS SQL Server ODBC driver on Amazon Linux 2023 EC2

0

I have tried to install the MS SQL Server ODBC driver based on the documentation on the Microsoft site, but it appears to lack the ability to do so for Amazon Linux 2023. The command script options show RHEL, but the code doesn't support the AL2023 version by default. It attempts to pull down the .rpm file from the web by grep-ing the version of the server and using that to path out the location. However, this is for the RHEL folders which don't appear to work with AL2023. There IS an amazonlinux folder that has the .rpm file, but when downloading this file and continuing with the Microsoft instructions for installing it, I get an error saying it can't find the "msodbcsql17" file when running a sudo yum install.

asked a year ago1.1K views

2 Answers
1

From what I can tell, Microsoft does not have official ODBC packages for AL20203. There is a open feature request in AL2023 GitHub.

You can try installing driver for RHEL 9. Just be aware that there is no support.

From Install the Microsoft ODBC driver for SQL Server (Linux)

curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo
sudo  dnf remove -q -y unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install -y msodbcsql18
sudo ACCEPT_EULA=Y yum install -y mssql-tools18
AWS
EXPERT

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

0

To install the Microsoft SQL Server ODBC driver on Amazon Linux 2023, you need to follow a different approach than the standard Microsoft documentation since Amazon Linux 2023 has specific requirements.

For Amazon Linux 2023, you'll need to:

  1. Install the required dependencies first:
sudo dnf install php-odbc unixODBC-devel -y
  1. Then install the SQL Server drivers using PECL:
sudo pecl install sqlsrv
sudo tee /etc/php.d/20-sqlsrv.ini > /dev/null << EOF
extension=sqlsrv.so
EOF

sudo pecl install pdo_sqlsrv
sudo tee /etc/php.d/30-pdo_sqlsrv.ini > /dev/null << EOF
extension=pdo_sqlsrv.so
EOF

The issue you're encountering is common because Amazon Linux 2023's repository structure differs from RHEL, even though they share some similarities. The standard Microsoft installation scripts are designed primarily for Ubuntu and RHEL distributions, not specifically for Amazon Linux 2023.

If you're trying to install the Microsoft ODBC driver for connecting to SQL Server from other applications (not PHP), you might need to download the appropriate package directly from Microsoft's repositories and install it manually, ensuring you select the correct version compatible with Amazon Linux 2023.
Sources
Using/Installing Microsoft SQL Server Driver in Amazon Linux 2023 | AWS re:Post
Deploy ec2 AMI with sql 2022 web edition - amazon linux based | AWS re:Post

answered a year ago

  • In my case, I need to access the SQL Server from a non-PHP application so the above suggestions don't apply for me. I've tried researching what exactly needs to be manually downloaded/installed and none of the answers are clear enough, or the commands that I run still can't install it successfully.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.