Connect to the VM
-
Find the IP address of your VM in the portal, Overview section.
-
Connect to the Azure VM using the ssh command. In the following command, replace the VM user name and IP address to connect to your Linux VM.
ssh [email protected]
Change the SA password
The new virtual machine installs SQL Server with a random SA password. Reset this password before you connect to SQL Server with the SA login.
-
Change the SA password with the following commands:
sudo systemctl stop mssql-server
sudo /opt/mssql/bin/mssql-conf set-sa-password
-
Enter a new SA password and password confirmation when prompted.
-
Restart the SQL Server service.
sudo systemctl start mssql-server
Add the tools to your path (optional)
Several SQL Server packages are installed by default, including the SQL Server command-line Tools package. The tools package contains the sqlcmd and bcp tools. For convenience, you can add the tools path, /opt/mssql-tools/bin/, to your PATH environment variable.
- Run the following commands to modify the PATH for both login sessions and interactive/non-login sessions:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Configure for remote connections
In order to remotely connect to SQL Server on the Azure VM, you must configure an inbound rule on the network security group. The rule allows traffic on the port on which SQL Server listens (default of 1433)
-
In the portal, select Virtual machines, and then select your SQL Server VM.
-
In the left navigation pane, under Settings, select Networking.
-
In the Networking window, select Add inbound port under Inbound Port Rules.
-
In the Service list, select MS SQL.
-
Click OK to save the rule for your VM.
Open the firewall
If you want to connect remotely to VMs, you also have to open up port 1433 on the Linux firewall.
- Connect to your VM.
- In the BASH shell, run the following command:
sudo ufw allow 1433/tcp
Connect
You can now connect to your server from your favorite client