In this article, we will be discussing about, how you can easily get started with SQL Server on Linux, mainly in terms of installing and managing different SQL Server services on Linux.
Introduction – SQL Server on Linux
SQL Server 2017 has been an amazing release of SQL Server. With an obvious decoupling between Windows and SQL Server, now you can run SQL Server on Linux, Docker containers, and even in macOS! This gives you more freedom regarding the platform on which you want to run SQL Server and that is just great. This article aims to help you getting started with SQL Server on Linux.
Linux Distributions Supported by SQL Server 2017
The Linux distributions supported by SQL Server 2017 are:
In this article I will mostly talk about Ubuntu since its free to use, but I will also be making some references to RedHat and SuSe Linux as well.
The major difference in the commands regarding the installation, upgrade, uninstallation and management of the SQL Server services across the above three Linux distributions, has to do with the different package managers they use.
Strengthen your SQL Server Administration Skills – Enroll to our Online Course!
Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!
(Lifetime Access/ Live Demos / Downloadable Resources and more!)
Installing SQL Server on Linux is very easy. Microsoft has available on their website excellent step-by-step documentation on how to perform the installation.
Below, I provide the links to this documentation/quickstarts:
We can briefly describe the installation experience by listing the Database Engine’s installation wizard steps:
Select SQL Server Edition (i.e. Developer Edition – Note: Developer Edition can be only used for development and not for Production purposes).
Review the License Terms
Set and confirm the SQL Server Server Administrator (SA) password
If all goes well, you will get the message that setup was succesfully completed and that SQL Server service is starting.
This article assumes that you have followed the above quickstart(s) and you have successfully installed SQL Server on your favorite Linux distribution.
Check the SQL Server Service Status After Installation
In Ubuntu Linux, in order to check the SQL Server service status at any time (i.e. right after the installation of SQL Server Database Engine) you can run the below command:
systemctl status mssql-server
systemctl is the utility that controls the systemd system and service manager.
If SQL Server service is running, right after you run the above command, you will get the message that SQL Server is “active (running)”.
Check for Updates
Another important task is to check for any updates for SQL Server. This can be done by comparing your current installation with the latest SQL Server version in the Linux repositories. This involves two steps:
Update the repository to its latest status by running the command (in Ubuntu):
sudo apt-get update
The above will update your repository status.
Please read the documentation for performing the above for the other two Linux distributions.
Upgrade SQL Server
For Ubuntu Linux:
sudo apt-get install mssql-server
For RedHat Linux (RHEL):
sudo yum update mssql-server
For SuSe Linux:
sudo zypper update mssql-server
The above will upgrade SQL Server, if necessary, or it will just report that you have the latest version installed.
Uninstalling SQL Server on Linux
If for any case, you need to uninstall your SQL Server installation on Linux, you can do so by running the below commands.
Critical Note:Always take care of your data in order not to lose it. For example, prior to uninstalling SQL Server, you need to backup your databases in a safe location.
Tip: You can find the location of your database files at: /var/opt/mssql/
Below you can find the uninstall commands:
For Ubuntu Linux:
sudo apt-get remove mssql-server
For RedHat Linux (RHEL):
sudo yum remove mssql-server
For SuSe Linux:
sudo zypper remove mssql-server
Managing SQL Server on Linux
It is very easy to mange the SQL Server service on Linux. As already mentioned above, you can do this with the systemctl utility.
Below you can find the commands for checking the status, stopping and starting SQL Server Database Engine service:
At the time of writing this article, you can install two command-line SQL Server client tools on Linux. These are:
sqlcmd: This is a command-line query utility.
bcp: This is a utility for Bulk import-export.
Both tools are well-known and easy to use, since they exist for Windows many years now.
To install these tools, you can follow the instructions on this MS Docs article.
Connecting to SQL Server on Linux from Windows
You might be wondering: “Is that possible?“. Of course it is! This is after all the real concept of portability.
So, to connect to your SQL Server instance on Linux, you will need what else rather than SQL Server Management Studio (SSMS)!
Note that you will need SSMS v.17 or later for being able to connect to your SQL Server instance on Linux.
Besides SSMS, you will need two simple details:
The IP of the Linux machine (note that in Linux you can only have one SQL Server instance)
The SA user’s password you set during the installation of SQL Server on Linux
Right after you make sure you have the above information, just enter the IP in the “Server Name” text box and after selecting “SQL Server Authentication” in the authentication type, enter the SA user’s credentials and click “Connect”. That’s it! You have just connected to your SQL Server instance on Linux via SSMS on Windows!
Did you find this article useful and interesting? Feel free to leave your comment!
Subscribe to our newsletterand stay up to date with our latest articles on SQL Server and related technologies!
Check out our latest software releases! All our software tools have Community Editions which are free to download.
Artemakis Artemiou is a seasoned Senior Database and AI/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.
Views:4,498
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent. Read More
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.