How to Install SQL Server on Linux
Installing SQL Server on a Linux environment provides a powerful combination of SQL Server’s capabilities and the flexibility of Linux. With SQL Server’s cross-platform support, you can deploy, manage, and scale your database applications on Linux with ease.
The installation process involves several steps, depending on the distribution of Linux you are using. This article outlines the methods for installing SQL Server on popular Linux distributions such as Ubuntu, Red Hat Enterprise Linux (RHEL), and SUSE Linux Enterprise Server (SLES).
How to Install MySQL Server on Linux?
Before installing SQL Server on Linux, ensure your system meets the minimum requirements:
- Operating System: SQL Server is supported on Ubuntu 18.04 and 20.04, Red Hat Enterprise Linux (RHEL) 8 and 9, and SUSE Linux Enterprise Server (SLES) 15.
- Memory: A minimum of 2 GB is required, but 4 GB or more is recommended for better performance.
- Processor: x64 processor with at least 2 cores.
- Disk Space: At least 6 GB of disk space for a basic installation.
- Internet Access: Required to download the installation packages.
How to Install SQL in Ubuntu?
For Ubuntu users, installing SQL Server involves adding the SQL Server repository to your system, followed by the installation of the SQL Server package. This method is straightforward and leverages Ubuntu’s native package management system.
To install SQL Server on Ubuntu, follow these steps:
Step 1: Import the public repository GPG keys
This step ensures the packages you download are authentic and unmodified. Open the terminal and run:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Step 2: Register the Microsoft SQL Server Ubuntu repository
Adding the repository allows you to download SQL Server packages directly from Microsoft’s repository.
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"
Step 3: Install SQL Server
After adding the repository, you need to update your system packages and then install SQL Server:
sudo apt-get update
sudo apt-get install -y mssql-server
Step 4: Configure SQL Server
Once the installation is complete, you must run the setup script to configure SQL Server:
sudo /opt/mssql/bin/mssql-conf setup
Follow the prompts to select your edition (such as Developer or Express) and set the SA (system administrator) password.
How to install SQL on Red Hat Enterprise Linux (RHEL)?
Installing SQL Server on RHEL requires a similar approach to that of Ubuntu but with a few differences tailored to the RHEL environment.
1. The process begins with adding the Microsoft SQL Server repository to your RHEL system.
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2022.repo
2. After setting up the repository, it’s necessary to install the SQL Server package using the yum package manager. The yum command will fetch the SQL Server package from the repository and handle the installation.
sudo yum install -y mssql-server
During the installation, you will configure SQL Server by setting the SA password and selecting the appropriate edition.
3. Once the installation is complete, enabling and starting the SQL Server service is required to make SQL Server operational. This involves using system management commands to ensure SQL Server starts automatically on boot and runs consistently without manual intervention.
sudo /opt/mssql/bin/mssql-conf setup
How to Install SQL Server on SUSE Linux Enterprise Server (SLES)?
On SLES, installing SQL Server follows a similar procedure to Ubuntu and RHEL but utilizes the zypper package manager instead.
Initially, adding the Microsoft SQL Server repository to your system is required. This involves creating a repository file and configuring it with the necessary repository details.
sudo curl -o /etc/zypp/repos.d/mssql-server.repo https://packages.microsoft.com/config/sles/15/mssql-server-2022.repo
Once the repository is added, refreshing the package list allows your system to recognize the available SQL Server packages.
Next, the installation of SQL Server is handled by zypper, which will download and install the necessary packages from the Microsoft repository.
sudo zypper install -y mssql-server
Configuration of SQL Server is required during the installation to set up your SA password and select the edition you need.
sudo /opt/mssql/bin/mssql-conf setup
After installing SQL Server, you must enable and start the service to ensure it runs correctly. This involves using system management commands specific to SLES to enable the service to start on boot and run continuously.
Frequently Asked Questions
Can SQL Server run natively on Linux without any emulation layers?
SQL Server can run natively on Linux. Microsoft has developed a version of SQL Server that is compatible with Linux operating systems, eliminating the need for emulation layers or virtual machines.
How to open SQL in Ubuntu terminal?
To open SQL in Ubuntu terminal, install MySQL using `sudo apt install mysql-server`. Then, run `mysql` to start the interactive shell. Use `use` to connect to a database.
Conclusion
So, that’s about it. You can now leverage the powerful features of SQL Server to manage and analyze your data. Remember to keep your installation updated with the latest patches and security fixes. Additionally, explore the various tools and resources available to enhance your SQL Server experience.