You’re an existing SQL Server customer and are looking to explore the fast-growing Linux operating system. Whether on-premises or in the cloud, Microsoft has you covered. With SQL Server 2017, and now SQL Server 2019, SQL Server is available on Red Hat Enterprise Linux, SUSE Linux Enterprise Server, and Ubuntu.
For our purposes, I’m going to walk through how to use the Azure portal to create a Linux virtual machine with SQL Server 2017 or 2019 installed. If you’re following along, you’ll need an Azure subscription. If you don’t already have one, sign up for an Azure free account. Alternatively, if you know which options you’re going to select, you can create a Linux virtual machine with the Azure command-line interface. Or, if you want to learn more about the benefits of SQL Server in Azure, download Future-Proof Your Data Infrastructure with Azure: A Business Case for Database Administrators.
First, we’ll create a Linux virtual machine with SQL Server installed:
- Sign in to the Azure portal.
- Select Create a resource, and then Compute.
- Next to the Featured heading, select See all.
- In the search box, type SQL Server 2019, and select Enter.
- You can limit the search results by operating system. To do so, select Operating system > Red Hat.
- Select a SQL Server 2019 image from the search results.
- Select Create.
The next step is to set up your Linux virtual machine:
- In the Basics tab, select your Subscription and Resource Group.
- In virtual machine name, enter a name for your new Linux virtual machine.
- Type or select the following, based on your requirements such as region, availability options, and change size.
- For authentication type, select SSH public key. (SSH is more secure than a password.)
- For username, enter the administrator’s name.
- For SSH public key, enter your Rivest–Shamir–Adleman (RSA) public key.
- For public inbound ports, choose allow selected ports and choose the SSH (22) port in the select public inbound ports.
- You can change or keep the default settings for disks, networking, management, guest configuration, and tags.
- Select Review and Create, and then select Create.
Next, connect to the Linux virtual machine. If you use a BASH shell, connect to the Azure virtual machine using the SSH command. In the following command, replace the virtual machine username and IP address to connect to your Linux virtual machine, and you can find the IP address of your virtual machine in the Azure portal:
If you don’t have a BASH shell, install an SSH client like PuTTY.
The new virtual machine installs SQL Server with a random system administrator (SA) password, so you’ll need to reset the password before connecting to SQL Server with the system administrator login:
- After connecting to the Linux virtual machine, open a new command terminal.
- Change the system administrator password with the following commands:
sudo systemctl stop mssql-server
sudo /opt/mssql/bin/mssql-conf set-sa-password
When prompted, enter a new system administrator password and password confirmation.
- Finally, restart the SQL Server service:
sudo systemctl start mssql-server
You’ve just provisioned a SQL Server 2017 virtual machine in Azure! You can connect to it locally with sqlcmd to run Transact-SQL queries or you can configure the Azure virtual machine for remote SQL Server connections. The best part is, you now have a full version of SQL Server in the cloud. There’s no need to manage on-premises hardware or secure the budget to procure and manage that hardware. Plus, the images are pay-as-you-go, so you only pay for what you use.
To learn more about moving your databases to the cloud, download Future-Proof Your Data Infrastructure with Azure: A Business Case for Database Administrators or check out the SQL Server on RHEL Azure VMs Operations Guide.