If you face “Microsoft ODBC Driver 13 for SQL Server: Data source name not found, and no default driver specified.” error while trying to access your SQL Server on Linux then most probably you are missing Microsoft ODBC Driver 13 for SQL Server on your machine. Here is how to install this driver.
To solve this problem I took this script and it worked fine for Ubuntu 16.04. Here is the script you need to run to install Microsoft ODBC Driver 13 for SQL Server on Ubuntu:
#!/bin/bash sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo -i export CPPFLAGS="-DSIZEOF_LONG_INT=8" sudo apt-get -y install gcc-5 g++-5 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 cd ~ echo "Configuring the unixODBC 2.3.1 Driver Manager" wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz tar -xzf unixODBC-2.3.1.tar.gz cd unixODBC-2.3.1/ ./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE 1> odbc_con.log 2> make_err.log echo "Building and Installing the unixODBC 2.3.1 Driver Manager" sudo make 1> make_std.log 2> make_err.log sudo make install 1> makeinstall_std.log 2> makeinstall_err.log cd ~ echo "Downloading the Microsoft ODBC Driver 13 for SQL Server - Ubuntu" wget "https://meetsstorenew.blob.core.windows.net/contianerhd/Ubuntu%2013.0%20Tar/msodbcsql-13.0.0.0.tar.gz?st=2016-10-18T17%3A29%3A00Z&se=2022-10-19T17%3A29%3A00Z&sp=rl&sv=2015-04-05&sr=b&sig=cDwPfrouVeIQf0vi%2BnKt%2BzX8Z8caIYvRCmicDL5oknY%3D" -O msodbcsql-13.0.0.0.tar.gz tar -xzf msodbcsql-13.0.0.0.tar.gz cd msodbcsql-13.0.0.0/ echo "Installing Dependencies" sudo apt-get -y install libssl1.0.0 sudo apt-get -y install libgss3 sudo echo "/usr/lib64" >> /etc/ld.so.conf sudo ldconfig echo "Installing the Microsoft ODBC Driver 13 for SQL Server - Ubuntu" sudo bash ./install.sh install --force --accept-license cd ~ echo "Compiling PHP driver" sudo apt-get -y install php7.0-dev wget https://github.com/Microsoft/msphpsql/archive/4.0.6-Linux.tar.gz tar -xzf 4.0.6-Linux.tar.gz cd msphpsql-4.0.6-Linux/source/pdo_sqlsrv/ phpize && ./configure CXXFLAGS=-std=c++11 && make sudo make install echo "Enabling Driver for php7.0-fpm and CLI" sudo bash -c 'echo -e "; configuration for php common module \n; priority=10 \nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini' sudo ln -s /etc/php/7.0/mods-available/pdo_sqlsrv.ini /etc/php/7.0/fpm/conf.d/20-pdo_sqlsrv.ini sudo ln -s /etc/php/7.0/mods-available/pdo_sqlsrv.ini /etc/php/7.0/cli/conf.d/20-pdo_sqlsrv.ini cd ~ echo "Cleaning up.." sudo rm -rf msphpsql-4.0.6-Linux/ sudo rm -rf unixODBC-2.3.1/ sudo rm -rf msodbcsql-13.0.0.0/ sudo rm 4.0.6-Linux.tar.gz sudo rm msodbcsql-13.0.0.0.tar.gz sudo rm unixODBC-2.3.1.tar.gz echo "All done, please be sure to test via the CLI & restart php7.0-fpm once complete." php -i | grep 'PDO drivers'
Save this script to a file (say installodbc.sh), add the execute attribute, and run it:
nano installodbc.sh chmod +x installodbc.sh sudo ./installodbc.sh
It doesn’t work: my pc doesn’t recognize the php and phpize command
What’s your OS?
Error executing wget “https://meetsstorenew.blob.core.windows.net/contianerhd/Ubuntu%2013.0%20Tar/msodbcsql-13.0.0.0.tar.gz?st=2016-10-18T17%3A29%3A00Z&se=2022-10-19T17%3A29%3A00Z&sp=rl&sv=2015-04-05&sr=b&sig=cDwPfrouVeIQf0vi%2BnKt%2BzX8Z8caIYvRCmicDL5oknY%3D” -O msodbcsql-13.0.0.0.tar.gz
ERROR 403: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including signature