Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/MicrosoftDocs/sql-docs-pr i…
Browse files Browse the repository at this point in the history
…nto sqluuf
  • Loading branch information
markingmyname committed Dec 23, 2024
2 parents 05f1be6 + 901a89e commit 2d905ed
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/linux/quickstart-install-connect-clouds.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ In this quickstart, you install [!INCLUDE [ssnoversion-md](../includes/ssnoversi
- [Quickstart: Install SQL Server and create a database on Red Hat](quickstart-install-connect-red-hat.md)
- [Quickstart: Install SQL Server and create a database on SUSE Linux Enterprise Server](quickstart-install-connect-suse.md)
- [Quickstart: Install SQL Server and create a database on Ubuntu](quickstart-install-connect-ubuntu.md)
- [Quickstart: Install SQL Server and create a database on WSL2](quickstart-install-connect-wsl-2.md)
1. Configure for remote connections:
- Open the [Amazon EC2 console]( https://console.aws.amazon.com/ec2/)
- In the navigation pane, choose **Security Groups**.
Expand Down
199 changes: 199 additions & 0 deletions docs/linux/quickstart-install-connect-wsl-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
---
title: "WSL 2: Install SQL Server on Windows Subsystem for Linux"
description: This quickstart shows how to install SQL Server on Windows Subsystem for Linux (WSL 2) and then create and query a database with sqlcmd.
author: rwestMSFT
ms.author: randolphwest
ms.date: 12/23/2024
ms.service: sql
ms.subservice: linux
ms.topic: conceptual
ms.custom:
- intro-installation
- linux-related-content
---
# Quickstart: Install SQL Server and create a database on Windows Subsystem for Linux (WSL 2)

[!INCLUDE [SQL Server - Linux](../includes/applies-to-version/sql-linux.md)]

Windows Subsystem for Linux (WSL) is a feature in Windows that allows you to run a Linux environment directly on your Windows machine, without the need for a virtual machine or dual booting. WSL provides a seamless and productive experience for developers who want to use both Windows and Linux simultaneously. For more information, see [What is the Windows Subsystem for Linux?](/windows/wsl/about)

## SQL Server on WSL is for development use only

SQL Server on WSL 2 is intended for development purposes only, and is **not** supported for production workloads. We recommend running SQL Server in WSL environments on one of the [Supported platforms](sql-server-linux-release-notes-2022.md#supported-platforms) as documented, for the version of SQL Server you intend to run.

For any support related issues, you can [obtain support from Microsoft](/troubleshoot/sql/database-engine/install/windows/support-policy-sql-server#obtain-support-from-microsoft).

## Get started with SQL Server on WSL 2

There are two ways to get started with SQL Server on WSL 2:

- Install SQL Server as a `systemd` service, which can be managed using `systemctl` commands. Make sure that you enable `systemd` on WSL. For more information, see [How to enable systemd](/windows/wsl/systemd#how-to-enable-systemd).

- Deploy SQL Server containers in WSL. For this option, you need to install a Linux container engine in WSL, such as Docker or Podman, and then deploy SQL Server containers.

## Prerequisites

Install WSL 2. Ensure you're running Windows 10 version 2004 or a later version (Build 19041 and higher), or Windows 11. To install WSL, open a PowerShell or Windows command prompt in administrator mode, and run the following command:

```console
wsl --install
```

For detailed instructions, see [How to install Linux on Windows with WSL](/windows/wsl/install). For information on setting up the WSL environment for development, see [Set up a WSL development environment](/windows/wsl/setup/environment).

## Install SQL Server in WSL

This section describes the steps to set up a Linux distribution in WSL, and how to install SQL Server in that Linux distribution.

### Choose Linux distribution

You can list all the valid distributions that can be installed in WSL using the following command:

```console
wsl -l -o
```

The output looks similar to the following example.

```output
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
NAME                            FRIENDLY NAME
Ubuntu                          Ubuntu
Debian                          Debian GNU/Linux
kali-linux                      Kali Linux Rolling
Ubuntu-18.04                    Ubuntu 18.04 LTS
Ubuntu-20.04                    Ubuntu 20.04 LTS
Ubuntu-22.04                    Ubuntu 22.04 LTS
Ubuntu-24.04                    Ubuntu 24.04 LTS
OracleLinux_7_9                 Oracle Linux 7.9
OracleLinux_8_7                 Oracle Linux 8.7
OracleLinux_9_1                 Oracle Linux 9.1
openSUSE-Leap-15.6              openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5
SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6
openSUSE-Tumbleweed             openSUSE Tumbleweed
```

For this quickstart, install Ubuntu 22.04, and then install SQL Server 2022 into that distribution.

To install Ubuntu 22.04, run the following command. Make a note of the UNIX user account and password. In this example, use `wsluser` as the username.

```console
wsl --install -d Ubuntu-22.04
```

You should see output similar to the following example. At the end, it should show that you're logged into the Ubuntu 22.04 bash shell.

```output
Installing: Ubuntu 22.04 LTS
Ubuntu 22.04 LTS has been installed.
Launching Ubuntu 22.04 LTS...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: wsluser
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro
 System information as of Tue Dec  3 00:32:14 IST 2024
  System load:  0.33                Processes:             32
  Usage of /:   0.1% of 1006.85GB   Users logged in:       0
  Memory usage: 2%                  IPv4 address for eth0: 10.18.123.249
  Swap usage:   0%
This message is shown once a day. To disable it please create the
/home/wsluser/.hushlogin file.
```

### Install SQL Server

Once you're logged into the Ubuntu 22.04 bash shell, you can follow the steps outlined in [Quickstart: Install SQL Server and create a database on Ubuntu](quickstart-install-connect-ubuntu.md?view=sql-server-ver16&preserve-view=true&tabs=ubuntu2204#install-sql-server) to install SQL Server 2022.

You should [install the SQL Server command-line tools](quickstart-install-connect-ubuntu.md?view=sql-server-ver16&preserve-view=true&tabs=ubuntu2204#install-the-sql-server-command-line-tools) as well.

### Get IP address

To identify the IP address to connect to using SQL Server Management Studio (SSMS), run the `ifconfig` command as follows:

```bash
ifconfig
```

You should see output similar to the following example.

```output
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.19.50.241  netmask 255.255.240.0  broadcast 10.19.63.255
        inet6 fe80::215:5dff:fe76:c05d  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:76:c0:5d  txqueuelen 1000  (Ethernet)
        RX packets 2146  bytes 1452448 (1.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1905  bytes 345288 (345.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2039  bytes 4144340 (4.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2039  bytes 4144340 (4.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

## Deploy SQL Server containers in WSL

To deploy containers in WSL, you first need to install a Linux container engine, such as Docker. For more information, see [Get started with Docker remote containers on WSL](/windows/wsl/tutorials/wsl-containers). Once you have the Docker engine installed, deploy the SQL Server container image as follows.

```bash
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<password>" \
-e "MSSQL_PID=Developer" -e "MSSQL_AGENT_ENABLED=true" \
-p 14333:1433 --name sqlcontainerwsl --hostname sqlcontainerwsl \
-d mcr.microsoft.com/mssql/server:2022-latest
```

> [!NOTE]
> [!INCLUDE [password-complexity](includes/password-complexity.md)]
### Add persistent storage with WSL for SQL Server containers

You can create data volumes as described in [Mount a host directory as data volume](sql-server-linux-docker-container-configure.md?pivots=cs1-bash#mount-a-host-directory-as-data-volume).

For example, run the following command to set up a volume called `sql_volume` located at `/var/opt/mssql/`.

```bash
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<password>" \
-e "MSSQL_PID=Developer" -e "MSSQL_AGENT_ENABLED=true" \
-p 14333:1433 --name sqlcontainerwsl --hostname sqlcontainerwsl \
-v sql_volume:/var/opt/mssql/ \
-d mcr.microsoft.com/mssql/server:2022-latest
```

Even if you run the `wsl --terminate` command, the data isn't lost. When you start up WSL again and run the `docker run` command to deploy using the `sql_volume` volume, it still has all the data intact.

If you want to delete the persisted volume, make sure that the container using the volume is stopped and removed, and run the following command.

```bash
docker volume rm sql_volume
```

## Remarks

You should be able to configure most of the features supported for SQL Server on Linux for development purposes, except the business continuity features that are dependent on clustering stacks. These features, such as Pacemaker or HPE Serviceguard, aren't supported on WSL.

For a full list of unsupported features for SQL Server on Linux, see [Editions and supported features of SQL Server 2022 on Linux](sql-server-linux-editions-and-components-2022.md).

[!INCLUDE [Connect, create, and query data](includes/quickstart-connect-query.md)]
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ helpviewer_keywords:
- "editions [SQL Server], about edition options"
- "Setup [SQL Server]"
---
# Editions and supported features of [!INCLUDE [sssql22](../includes/sssql22-md.md)] on Linux
# Editions and supported features of SQL Server 2022 on Linux

[!INCLUDE [SQL Server - Linux](../includes/applies-to-version/sql-linux.md)]

Expand Down
2 changes: 1 addition & 1 deletion docs/linux/sql-server-linux-known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,5 @@ For Ubuntu 22.04, you should reach out to Canonical directly for the exact steps
## Related content
- [Release notes for SQL Server 2022 on Linux](sql-server-linux-release-notes-2022.md)
- [Editions and supported features of [!INCLUDE [sssql22](../includes/sssql22-md.md)] on Linux](sql-server-linux-editions-and-components-2022.md)
- [Editions and supported features of SQL Server 2022 on Linux](sql-server-linux-editions-and-components-2022.md)
- [Troubleshoot SQL Server on Linux](sql-server-linux-troubleshooting-guide.md)
2 changes: 1 addition & 1 deletion docs/linux/sql-server-linux-security-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ For more information about security features available in [!INCLUDE [ssnoversion

- [Walkthrough for the security features of SQL Server on Linux](sql-server-linux-security-get-started.md)
- [Configure SQL Server on Linux with the mssql-conf tool](sql-server-linux-configure-mssql-conf.md)
- [Editions and supported features of [!INCLUDE [sssql22](../includes/sssql22-md.md)] on Linux](sql-server-linux-editions-and-components-2022.md)
- [Editions and supported features of SQL Server 2022 on Linux](sql-server-linux-editions-and-components-2022.md)
2 changes: 1 addition & 1 deletion docs/t-sql/language-elements/execute-transact-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ GO

### B. Use multiple parameters

The following example executes the `spGetWhereUsedProductID` stored procedure in the [!INCLUDE [ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database. It passes two parameters: the first parameter is a product ID (`819`) and the second parameter, `@CheckDate,` is a `datetime` value.
The following example executes the `spGetWhereUsedProductID` stored procedure in the [!INCLUDE [ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database. It passes two parameters: the first parameter is a product ID (`819`) and the second parameter `@CheckDate` is a **datetime** value.

```sql
DECLARE @CheckDate AS DATETIME;
Expand Down
2 changes: 2 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10113,6 +10113,8 @@ items:
href: linux/quickstart-install-connect-suse.md
- name: Install and connect (Ubuntu)
href: linux/quickstart-install-connect-ubuntu.md
- name: Install and connect (WSL2)
href: linux/quickstart-install-connect-wsl-2.md
- name: Run and connect (containers)
href: linux/quickstart-install-connect-docker.md
- name: Deploy SQL Server container cluster
Expand Down

0 comments on commit 2d905ed

Please sign in to comment.