- Installation guidance for SQL Server on Linux
- Supported platforms
- System requirements
- Configure source repositories
- Install SQL Server
- Update or upgrade SQL Server
- Rollback SQL Server
- Check installed SQL Server version
- Uninstall SQL Server
- Unattended install
- Offline install
- Licensing and pricing
- Optional SQL Server features
- Get help
- Quickstart: Install SQL Server and create a database on Ubuntu
- Azure Marketplace images
- Prerequisites
- Install SQL Server
- Install the SQL Server command-line tools
- Connect locally
- Create and query data
- Create a new database
- Insert data
- Select data
- Exit the sqlcmd command prompt
- Performance best practices
- Cross-platform data tools
- Connecting from Windows
- Other deployment scenarios
- Next steps
- Connect locally
- Create and query data
- Create a new database
- Insert data
- Select data
- Exit the sqlcmd command prompt
- Performance best practices
- Cross-platform data tools
- Connecting from Windows
- Other deployment scenarios
- Next steps
- Connect locally
- Create and query data
- Create a new database
- Insert data
- Select data
- Exit the sqlcmd command prompt
- Performance best practices
- Cross-platform data tools
- Connecting from Windows
- Other deployment scenarios
Installation guidance for SQL Server on Linux
Applies to: SQL Server (all supported versions) — Linux
This article provides guidance for installing, updating, and uninstalling SQL Server 2017 (14.x), SQL Server 2019 (15.x), and SQL Server 2022 (16.x) Preview on Linux.
For other deployment scenarios, see:
This guide covers several deployment scenarios. If you are only looking for step-by-step installation instructions, jump to one of the quickstarts:
For answers to frequently asked questions, see the SQL Server on Linux FAQ.
Supported platforms
SQL Server is supported on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu. It is also supported as a Docker image, which can run on Docker Engine on Linux.
Platform | File System | Installation Guide |
---|---|---|
Red Hat Enterprise Linux 7.7 — 7.9, or 8.0 — 8.6 Server | XFS or EXT4 | Installation guide |
SUSE Enterprise Linux Server v12 SP3 — SP5 | XFS or EXT4 | Installation guide |
Ubuntu 16.04 LTS 1 , 18.04 LTS | XFS or EXT4 | Installation guide |
Docker Engine 1.8+ on Linux | N/A | Installation guide |
1 Support for SQL Server on Ubuntu 16.04 is limited. At the end of April 2021, Ubuntu 16.04 transitioned from its standard five-year maintenance window for long term support (LTS) releases, into extended security maintenance (ESM) support. For more details, see Ubuntu 16.04 LTS transitions to Extended Security Maintenance (ESM) | Ubuntu.
For more information, review the system requirements for SQL Server on Linux. For the latest support policy for SQL Server, see the Technical support policy for Microsoft SQL Server.
Platform | File System | Installation Guide | Get |
---|---|---|---|
Red Hat Enterprise Linux 7.7 — 7.9, or 8.0 — 8.6 Server | XFS or EXT4 | Installation guide | Get RHEL 8.0 |
SUSE Enterprise Linux Server v12 (SP3 — SP5), or v15 (SP1 — SP3) | XFS or EXT4 | Installation guide | Get SLES v15 |
Ubuntu 16.04 LTS 1 , 18.04 LTS, 20.04 LTS | XFS or EXT4 | Installation guide | Get Ubuntu 20.04 |
Docker Engine 1.8+ on Windows, Mac, or Linux | N/A | Installation guide | Get Docker |
1 Support for SQL Server on Ubuntu 16.04 is limited. At the end of April 2021, Ubuntu 16.04 transitioned from its standard five-year maintenance window for long term support (LTS) releases, into extended security maintenance (ESM) support. For more details, see Ubuntu 16.04 LTS transitions to Extended Security Maintenance (ESM) | Ubuntu.
For more information, review the system requirements for SQL Server on Linux. For the latest support policy for SQL Server, see the Technical support policy for Microsoft SQL Server.
Platform | File System | Installation Guide | Get |
---|---|---|---|
Red Hat Enterprise Linux 8.0 — 8.6 Server | XFS or EXT4 | Installation guide | Get RHEL 8.0 |
SUSE Enterprise Linux Server v15 (SP1 — SP3) | XFS or EXT4 | Installation guide | Get SLES v15 |
Ubuntu 20.04 LTS | XFS or EXT4 | Installation guide | Get Ubuntu 20.04 |
Docker Engine 1.8+ on Linux | N/A | Installation guide | Get Docker |
For more information, review the system requirements for SQL Server on Linux. For the latest support policy for SQL Server, see the Technical support policy for Microsoft SQL Server.
Microsoft also supports deploying and managing SQL Server containers by using OpenShift and Kubernetes.
SQL Server is tested and supported on Linux for the previously listed distributions. If you choose to install SQL Server on an unsupported operating system, please review the Support policy section of the Technical support policy for Microsoft SQL Server to understand the support implications.
System requirements
SQL Server has the following system requirements for Linux:
Requirement | |
---|---|
Memory | 2 GB |
File System | XFS or EXT4 (other file systems, such as BTRFS, are not supported) |
Disk space | 6 GB |
Processor speed | 2 GHz |
Processor cores | 2 cores |
Processor type | x64-compatible only |
If you use Network File System (NFS) remote shares in production, note the following support requirements:
- Use NFS version 4.2 or higher. Older versions of NFS do not support required features, such as fallocate and sparse file creation, common to modern file systems.
- Locate only the /var/opt/mssql directories on the NFS mount. Other files, such as the SQL Server system binaries, are not supported.
- Ensure that NFS clients use the ‘nolock’ option when mounting the remote share.
Configure source repositories
When you install or upgrade SQL Server, you get the latest version of SQL Server from your configured Microsoft repository. The quickstarts use the Cumulative Update CU repository for SQL Server. For more information on repositories and how to configure them, see Configure repositories for SQL Server on Linux.
Install SQL Server
You can install SQL Server on Linux from the command line. For step-by-step instructions, see one of the following quickstarts:
Platform | Installation quickstarts |
---|---|
Red Hat Enterprise Linux (RHEL) | 2017 | 2019 | 2022 |
SUSE Linux Enterprise Server (SLES) | 2017 | 2019 | 2022 |
Ubuntu | 2017 | 2019 | 2022 |
Docker | 2017 | 2019 | 2022 |
You can also run SQL Server on Linux in an Azure virtual machine. For more information, see Provision a SQL VM in Azure.
After installing, consider making additional configuration changes for optimal performance. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.
Update or upgrade SQL Server
To update the mssql-server package to the latest release, use one of the following commands based on your platform:
Platform | Package update command(s) |
---|---|
RHEL | sudo yum update mssql-server |
SLES | sudo zypper update mssql-server |
Ubuntu | sudo apt-get update sudo apt-get install mssql-server |
These commands download the newest package and replace the binaries located under /opt/mssql/ . The user generated databases and system databases are not affected by this operation.
To upgrade SQL Server, first change your configured repository to the desired version of SQL Server. Then use the same update command to upgrade your version of SQL Server. This is only possible if the upgrade path is supported between the two repositories.
Rollback SQL Server
To rollback or downgrade SQL Server to a previous release, use the following steps:
Identify the version number for the SQL Server package you want to downgrade to. For a list of package numbers, see the Release notes.
Downgrade to a previous version of SQL Server. In the following commands, replace with the SQL Server version number you identified in step one.
Platform | Package update command(s) |
---|---|
RHEL | sudo yum downgrade mssql-server- .x86_64 |
SLES | sudo zypper install —oldpackage mssql-server= |
Ubuntu | sudo apt-get install mssql-server= sudo systemctl start mssql-server |
It is only supported to downgrade to a release within the same major version, such as SQL Server 2019.
Check installed SQL Server version
To verify your current version and edition of SQL Server on Linux, use the following procedure:
If not already installed, install the SQL Server command-line tools.
Use sqlcmd to run a Transact-SQL command that displays your SQL Server version and edition.
Uninstall SQL Server
To remove the mssql-server package on Linux, use one of the following commands based on your platform:
Platform | Package removal command(s) |
---|---|
RHEL | sudo yum remove mssql-server |
SLES | sudo zypper remove mssql-server |
Ubuntu | sudo apt-get remove mssql-server |
Removing the package does not delete the generated database files. If you want to delete the database files, use the following command:
Unattended install
You can perform an unattended installation in the following way:
- Follow the initial steps in the quickstarts to register the repositories and install SQL Server.
- When you run mssql-conf setup , set environment variables and use the -n (no prompt) option.
The following example configures the Developer edition of SQL Server with the MSSQL_PID environment variable. It also accepts the EULA (ACCEPT_EULA) and sets the SA user password (MSSQL_SA_PASSWORD). The -n parameter performs an unprompted installation where the configuration values are pulled from the environment variables.
You can also create a script that performs other actions. For example, you could install other SQL Server packages.
For a more detailed sample script, see the following examples:
Offline install
If your Linux machine does not have access to the online repositories used in the quick starts, you can download the package files directly. These packages are located in the Microsoft repository, https://packages.microsoft.com.
If you successfully installed with the steps in the quick starts, you do not need to download or manually install the SQL Server package(s). This section is only for the offline scenario.
Download the database engine package for your platform. Find package download links in the package details section of the Release Notes.
Move the downloaded package to your Linux machine. If you used a different machine to download the packages, one way to move the packages to your Linux machine is with the scp command.
Install the database engine package. Use one of the following commands based on your platform. Replace the package file name in this example with the exact name you downloaded.
Platform | Package install command |
---|---|
RHEL | sudo yum localinstall mssql-server_versionnumber.x86_64.rpm |
SLES | sudo zypper install mssql-server_versionnumber.x86_64.rpm |
Ubuntu | sudo dpkg -i mssql-server_versionnumber_amd64.deb |
You can also install the RPM packages (RHEL and SLES) with the rpm -ivh command, but the commands in the previous table automatically install dependencies if available from approved repositories.
Resolve missing dependencies: You might have missing dependencies at this point. If not, you can skip this step. On Ubuntu, if you have access to approved repositories containing those dependencies, the easiest solution is to use the apt-get -f install command. This command also completes the installation of SQL Server. To manually inspect dependencies, use the following commands:
Platform | List dependencies command |
---|---|
RHEL | rpm -qpR mssql-server_versionnumber.x86_64.rpm |
SLES | rpm -qpR mssql-server_versionnumber.x86_64.rpm |
Ubuntu | dpkg -I mssql-server_versionnumber_amd64.deb |
After resolving the missing dependencies, attempt to install the mssql-server package again.
Complete the SQL Server setup. Use mssql-conf to complete the SQL Server setup:
Licensing and pricing
SQL Server is licensed the same for Linux and Windows. For more information about SQL Server licensing and pricing, see How to license SQL Server.
Optional SQL Server features
After installation, you can also install or enable optional SQL Server features.
Get help
For answers to frequently asked questions, see the SQL Server on Linux FAQ.
Quickstart: Install SQL Server and create a database on Ubuntu
Applies to: SQL Server (all supported versions) — Linux
In this quickstart, you install SQL Server 2017 (14.x) on Ubuntu 18.04. Then you can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2017 on Linux.
In this quickstart, you install SQL Server 2019 (15.x) on Ubuntu 20.04. Then you can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2019 on Linux.
In this quickstart, you install SQL Server 2022 (16.x) Preview on Ubuntu 20.04. Then you can connect with sqlcmd to create your first database and run queries.
This tutorial requires user input and an internet connection. If you are interested in the unattended or offline installation procedures, see Installation guidance for SQL Server on Linux.
If you choose to have a pre-installed SQL Server VM on Ubuntu ready to run your production-based workload, then please follow the best practices for creating the SQL Server VM.
Azure Marketplace images
You can create your VM based on one of the following two Azure Marketplace images:
When you use these images, you avoid the installation step, and can directly configure the instance by providing the SKU and the sa password needed to get started with SQL Server. SQL Server Azure VMs deployed on Ubuntu Pro using the above Marketplace images, are fully supported by both Microsoft and Canonical.
You can configure SQL Server on Linux with mssql-conf, using the following command:
Prerequisites
You must have an Ubuntu 18.04 machine with at least 2 GB of memory.
To install Ubuntu 18.04 on your own machine, go to https://releases.ubuntu.com/18.04/. You can also create Ubuntu virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI.
You must have an Ubuntu 20.04 machine with at least 2 GB of memory.
To install Ubuntu 20.04 on your own machine, go to https://releases.ubuntu.com/20.04/. You can also create Ubuntu virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI.
You must have an Ubuntu 20.04 machine with at least 2 GB of memory.
To install Ubuntu 20.04 on your own machine, go to https://releases.ubuntu.com/20.04/. You can also create Ubuntu virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI.
If you’ve previously installed a Community Technology Preview (CTP) or Release Candidate (RC) of SQL Server, you must first remove the old repository before following these steps. For more information, see Configure Linux repositories for SQL Server.
The Windows Subsystem for Linux isn’t supported as an installation target for SQL Server.
Install SQL Server
To configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.
Import the public repository GPG keys:
Register the SQL Server Ubuntu repository:
If you want to install a different version of SQL Server, see the SQL Server 2019 (15.x) or SQL Server 2022 (16.x) Preview versions of this article.
Run the following commands to install SQL Server:
After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition. As a reminder, the following SQL Server editions are freely licensed: Evaluation, Developer, and Express.
Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.
Once the configuration is done, verify that the service is running:
If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
Import the public repository GPG keys:
Register the SQL Server Ubuntu repository:
If you want to install a different version of SQL Server, see the SQL Server 2017 (14.x) or SQL Server 2022 (16.x) Preview versions of this article.
Run the following commands to install SQL Server:
After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition. As a reminder, the following SQL Server editions are freely licensed: Evaluation, Developer, and Express.
Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.
Once the configuration is done, verify that the service is running:
If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
Import the public repository GPG keys:
Register the SQL Server Ubuntu repository:
If you want to install a different version of SQL Server, see the SQL Server 2017 (14.x) or SQL Server 2019 (15.x) versions of this article.
Run the following commands to install SQL Server:
After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition. As a reminder, the following SQL Server editions are freely licensed: Evaluation, Developer, and Express.
Remember to specify a strong password for the SA account. You need a minimum length 8 characters, including uppercase and lowercase letters, base-10 digits and/or non-alphanumeric symbols.
Once the configuration is done, verify that the service is running:
If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
At this point, SQL Server is running on your Ubuntu machine and is ready to use!
Install the SQL Server command-line tools
To create a database, you need to connect with a tool that can run Transact-SQL statements on SQL Server. The following steps install the SQL Server command-line tools: sqlcmd and bcp.
Use the following steps to install the mssql-tools on Ubuntu. If curl isn’t installed, you can run this code:
Import the public repository GPG keys.
Register the Ubuntu repository.
Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).
You can update to the latest version of mssql-tools using the following commands:
For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable, to make sqlcmd or bcp accessible from the bash shell.
For interactive sessions, modify the PATH environment variable in your
/.bash_profile file with the following command:
For non-interactive sessions, modify the PATH environment variable in your
/.bashrc file with the following command:
Connect locally
The following steps use sqlcmd to locally connect to your new SQL Server instance.
Run sqlcmd with parameters for your SQL Server name ( -S ), the user name ( -U ), and the password ( -P ). In this tutorial, you are connecting locally, so the server name is localhost . The user name is sa and the password is the one you provided for the SA account during setup.
You can omit the password on the command line to be prompted to enter it.
If you later decide to connect remotely, specify the machine name or IP address for the -S parameter, and make sure port 1433 is open on your firewall.
If successful, you should get to a sqlcmd command prompt: 1> .
If you get a connection failure, first attempt to diagnose the problem from the error message. Then review the connection troubleshooting recommendations.
Create and query data
The following sections walk you through using sqlcmd to create a new database, add data, and run a simple query.
For more information about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements.
Create a new database
The following steps create a new database named TestDB .
From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
On the next line, write a query to return the name of all of the databases on your server:
The previous two commands were not executed immediately. You must type GO on a new line to execute the previous commands:
Insert data
Next create a new table, dbo.Inventory , and insert two new rows.
From the sqlcmd command prompt, switch context to the new TestDB database:
Create new table named dbo.Inventory :
Insert data into the new table:
Type GO to execute the previous commands:
Select data
Now, run a query to return data from the dbo.Inventory table.
From the sqlcmd command prompt, enter a query that returns rows from the dbo.Inventory table where the quantity is greater than 152:
Execute the command:
Exit the sqlcmd command prompt
To end your sqlcmd session, type QUIT :
Performance best practices
After installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.
Cross-platform data tools
In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server:
Tool | Description |
---|---|
Azure Data Studio | A cross-platform GUI database management utility. |
Visual Studio Code | A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension. |
PowerShell Core | A cross-platform automation and configuration tool based on cmdlets. |
mssql-cli | A cross-platform command-line interface for running Transact-SQL commands. |
Connecting from Windows
SQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance.
If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. You must use the target Linux machine name or IP address rather than localhost , and make sure that TCP port 1433 is open on the SQL Server machine. If you have any problems connecting from Windows, see connection troubleshooting recommendations.
For other tools that run on Windows but connect to SQL Server on Linux, see:
Other deployment scenarios
For other installation scenarios, see the following resources:
- Upgrade: Learn how to upgrade an existing installation of SQL Server on Linux
- Uninstall: Uninstall SQL Server on Linux
- Unattended install: Learn how to script the installation without prompts
- Offline install: Learn how to manually download the packages for offline installation
For answers to frequently asked questions, see the SQL Server on Linux FAQ.
Next steps
Import the public repository GPG keys.
Register the Ubuntu repository.
Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).
You can update to the latest version of mssql-tools using the following commands:
For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable, to make sqlcmd or bcp accessible from the bash shell.
For interactive sessions, modify the PATH environment variable in your
/.bash_profile file with the following command:
For non-interactive sessions, modify the PATH environment variable in your
/.bashrc file with the following command:
Connect locally
The following steps use sqlcmd to locally connect to your new SQL Server instance.
Run sqlcmd with parameters for your SQL Server name ( -S ), the user name ( -U ), and the password ( -P ). In this tutorial, you are connecting locally, so the server name is localhost . The user name is sa and the password is the one you provided for the SA account during setup.
You can omit the password on the command line to be prompted to enter it.
If you later decide to connect remotely, specify the machine name or IP address for the -S parameter, and make sure port 1433 is open on your firewall.
If successful, you should get to a sqlcmd command prompt: 1> .
If you get a connection failure, first attempt to diagnose the problem from the error message. Then review the connection troubleshooting recommendations.
Create and query data
The following sections walk you through using sqlcmd to create a new database, add data, and run a simple query.
For more information about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements.
Create a new database
The following steps create a new database named TestDB .
From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
On the next line, write a query to return the name of all of the databases on your server:
The previous two commands were not executed immediately. You must type GO on a new line to execute the previous commands:
Insert data
Next create a new table, dbo.Inventory , and insert two new rows.
From the sqlcmd command prompt, switch context to the new TestDB database:
Create new table named dbo.Inventory :
Insert data into the new table:
Type GO to execute the previous commands:
Select data
Now, run a query to return data from the dbo.Inventory table.
From the sqlcmd command prompt, enter a query that returns rows from the dbo.Inventory table where the quantity is greater than 152:
Execute the command:
Exit the sqlcmd command prompt
To end your sqlcmd session, type QUIT :
Performance best practices
After installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.
Cross-platform data tools
In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server:
Tool | Description |
---|---|
Azure Data Studio | A cross-platform GUI database management utility. |
Visual Studio Code | A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension. |
PowerShell Core | A cross-platform automation and configuration tool based on cmdlets. |
mssql-cli | A cross-platform command-line interface for running Transact-SQL commands. |
Connecting from Windows
SQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance.
If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. You must use the target Linux machine name or IP address rather than localhost , and make sure that TCP port 1433 is open on the SQL Server machine. If you have any problems connecting from Windows, see connection troubleshooting recommendations.
For other tools that run on Windows but connect to SQL Server on Linux, see:
Other deployment scenarios
For other installation scenarios, see the following resources:
- Upgrade: Learn how to upgrade an existing installation of SQL Server on Linux
- Uninstall: Uninstall SQL Server on Linux
- Unattended install: Learn how to script the installation without prompts
- Offline install: Learn how to manually download the packages for offline installation
For answers to frequently asked questions, see the SQL Server on Linux FAQ.
Next steps
Import the public repository GPG keys.
Register the Ubuntu repository.
Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).
You can update to the latest version of mssql-tools using the following commands:
For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable, to make sqlcmd or bcp accessible from the bash shell.
For interactive sessions, modify the PATH environment variable in your
/.bash_profile file with the following command:
For non-interactive sessions, modify the PATH environment variable in your
/.bashrc file with the following command:
Connect locally
The following steps use sqlcmd to locally connect to your new SQL Server instance.
Run sqlcmd with parameters for your SQL Server name ( -S ), the user name ( -U ), and the password ( -P ). In this tutorial, you are connecting locally, so the server name is localhost . The user name is sa and the password is the one you provided for the SA account during setup.
You can omit the password on the command line to be prompted to enter it.
If you later decide to connect remotely, specify the machine name or IP address for the -S parameter, and make sure port 1433 is open on your firewall.
If successful, you should get to a sqlcmd command prompt: 1> .
If you get a connection failure, first attempt to diagnose the problem from the error message. Then review the connection troubleshooting recommendations.
Create and query data
The following sections walk you through using sqlcmd to create a new database, add data, and run a simple query.
For more information about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements.
Create a new database
The following steps create a new database named TestDB .
From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
On the next line, write a query to return the name of all of the databases on your server:
The previous two commands were not executed immediately. You must type GO on a new line to execute the previous commands:
Insert data
Next create a new table, dbo.Inventory , and insert two new rows.
From the sqlcmd command prompt, switch context to the new TestDB database:
Create new table named dbo.Inventory :
Insert data into the new table:
Type GO to execute the previous commands:
Select data
Now, run a query to return data from the dbo.Inventory table.
From the sqlcmd command prompt, enter a query that returns rows from the dbo.Inventory table where the quantity is greater than 152:
Execute the command:
Exit the sqlcmd command prompt
To end your sqlcmd session, type QUIT :
Performance best practices
After installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.
Cross-platform data tools
In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server:
Tool | Description |
---|---|
Azure Data Studio | A cross-platform GUI database management utility. |
Visual Studio Code | A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension. |
PowerShell Core | A cross-platform automation and configuration tool based on cmdlets. |
mssql-cli | A cross-platform command-line interface for running Transact-SQL commands. |
Connecting from Windows
SQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance.
If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. You must use the target Linux machine name or IP address rather than localhost , and make sure that TCP port 1433 is open on the SQL Server machine. If you have any problems connecting from Windows, see connection troubleshooting recommendations.
For other tools that run on Windows but connect to SQL Server on Linux, see:
Other deployment scenarios
For other installation scenarios, see the following resources:
- Upgrade: Learn how to upgrade an existing installation of SQL Server on Linux
- Uninstall: Uninstall SQL Server on Linux
- Unattended install: Learn how to script the installation without prompts
- Offline install: Learn how to manually download the packages for offline installation
For answers to frequently asked questions, see the SQL Server on Linux FAQ.