MySQL and SQL server provide high performance and scaling capabilities, however, SQL server ( MSSQL )has the advantage. For instance, according to this study, SQL Server consistently outperforms MySQL when it involves transactions on high volumes of data.
In addition, MySQL is considered to be Oracle’s “entry-level” database. In contrast, SQL server (MSSQL) is Microsoft’s flagship database. Usually, Oracle will Advice their customers to buy their flagship database Oracle Database.
Method 1: Install ODBC modules on Linux
apt update apt install -y unixodbc unixodbc-dev # Check which version of PHP apt install -y php-odbc php7.4-odbc
Method 2: Install SQL server native driver
Enable Microsoft repository.
Yep, Microsoft now has a repository for Linux. So, to complete this step.
First, Add Microsoft packages authentication keys “gpg keys” to your system.
Then, Create a repository file.
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
Install SQL Server tools for Linux
sudo apt-get update sudo ACCEPT_EULA=Y apt-get install msodbcsql17 # optional: for bcp and sqlcmd sudo ACCEPT_EULA=Y apt-get 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 apt-get install unixodbc-dev # optional: kerberos library for debian-slim distributions sudo apt-get install libgssapi-krb5-2
Install the ODBC driver for Debian by following the instructions on the Linux installation article.
Step 1. Setup Linux Locale.
sudo su sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen locale-gen
You may need to add /usr/sbin
to your $PATH
, as the locale-gen
executable is located there.
Step 2. Install Microsoft SQL Server drivers
The following commands customized for PHP 7.4 on debian that has multiple PHP versions. Thus you need to update it with your version
sudo pecl install sqlsrv sudo pecl install pdo_sqlsrv sudo su printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.4/mods-available/sqlsrv.ini printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.4/mods-available/pdo_sqlsrv.ini exit sudo phpenmod -v 7.4 sqlsrv pdo_sqlsrv
If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
Step 3. Restart PHP-FPM if you have it.
As we are adding modules for php. therefore, you will need to restart FastCGI Process Manager service.
systemctl restart php-fpm
Step 4. Install Apache and configure driver loading
sudo su apt-get install libapache2-mod-php7.4 apache2 a2dismod mpm_event a2enmod mpm_prefork a2enmod php7.4
Step 5. Restart Apache and test the sample script
sudo service apache2 restart
To test your installation, see Testing your installation at the end of this document.