Can I run SQL Server on Ubuntu?
You can certainly try the approach I will outline below but I don't know if anyone has tried it successfully.
- Install virtualization software on your Ubuntu machine (VMWare, Xen, VirtualBox).
- Install Microsoft Windows Server in the virtual machine.
- Install MS SQL Server on the newly installed Windows Server.
I don't know if any other way would work but people can correct me the MS SQL Server from what I can remember actually relies on Licensing for Microsoft Windows Server. On top of this SQLServer is a pretty bad resource hog so normally organizations try to segregate it from running with any other applications on it's own cluster or server.
One thing that I would question is why not try Sybase as the backend? The connectivity from Linux to SQLServer and Sybase can go through FreeTDS
, which would look identical to your client software.
WARNING: EMBRACE - EXTEND - DROP ?
Yes, as per end of November 2016, and as per docs.microsoft.com, you can install the public preview of sql-server vNext CTP1 on Ubuntu 16.04 (doesn't work on 14.04 because the OpenSSL-package is outdated, and doesn't work on 19.04 because the OpenSSL-package is too new):
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
sudo apt-get update
sudo apt-get install -y mssql-server
sudo /opt/mssql/bin/sqlservr-setup
or newer
sudo /opt/mssql/bin/mssql-conf setup
To remove it
sudo apt-get remove --purge mssql-server
To remove the generated databases
sudo rm -rf /var/opt/mssql/
If you want to check whether it works or not, do not forget to switch off the firewall
iptables -F
iptables -P INPUT ACCEPT
You can start SQL-Server with:
systemctl start mssql-server
You can stop SQL-Server with:
systemctl stop mssql-server
To see its status:
systemctl status mssql-server
To start sql-server at boot-time:
systemctl enable mssql-server
To disable SQL-Server-start at boot-time:
systemctl disable mssql-server
And if you also want the command-line tools
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update
sudo apt-get install mssql-tools
To test it
sqlcmd -S localhost -U SA -P 'YourPasswordHere'
CREATE DATABASE contoso
exit
And to permanently open port 1433 (sql-server default-port)
iptables -A INPUT -p tcp --dport 1433 -j ACCEPT
sudo apt-get install iptables-persistent
sudo netfilter-persistent save
sudo netfilter-persistent reload
or if you use ufw, you can do the same by typing less with
ufw allow 1433/tcp
See also firewall-persistence and this
For Red Hat (firewalld):
firewall-cmd --add-port=1433/tcp --permanent
firewall-cmd --reload
If you don't want to work with command-line tools, you can connect with SSMS from a windows laptop.
If you can't use sql-server on your distro (openssl too old / openssl too new / distro not supported), then you can always use the docker image:
sudo apt-get install docker.io
docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run -d -p 2017:1433 --name mssql_2017 -e MSSQL_SA_PASSWORD =TOP_SECRET -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -v /var/opt/mssql:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest
that installs docker, pulls the latest SQL-Server-2017 docker-linux-image from internet, and maps port 1433 in the container to port 2017 in the host, and sets the license to "Developer", the sa-Password to TOP_SECRET and it also maps /var/opt/mssql on the container to /var/opt/mssql on the host. You might have to create that folder with mkdir -p /var/opt/mssql
.
From there on, you can start the container with docker start mssql_2017
and stop the container with docker stop mssql_2017
.
To graphically work with sql-server on Linux, you can use AzureDataStudio, download the deb-package from its github page, and install it with sudo dpkg -i azuredatastudio-linux-1.12.2.deb