Exercise - Install SQL Server on SUSE
It's easy to install SQL Server on SUSE by using the zypper
tool.
You're a database administrator at the wholesale company Wide World Importers. You want to benefit from SQL Server without having to change the server operating systems. After you deploy SQL Server on a SUSE server, you can configure the SQL Server package and install command-line tools. SQL Server is then ready for use by your developers.
In this exercise, you see how to deploy SQL Server on SUSE, install command-line tools, and create a database.
Create a SUSE Virtual Machine
Use the Cloud Shell sandbox and Azure CLI commands to create a SUSE Enterprise server. The az vm create command can take a couple of minutes to complete.
export PASSWORD=$(openssl rand -base64 32) az vm create \ --name SLESSQLServer \ --resource-group <rgn>[sandbox resource group name]</rgn> \ --admin-username suseadmin \ --admin-password $PASSWORD \ --image "SUSE:sles-12-sp5:gen1:latest" \ --nsg-rule SSH \ --public-ip-sku Standard \ --size Standard_D2s_v3
Store the public IP address of your server, and display the password.
export IPADDRESS=$(az vm show -d \ --name SLESSQLServer \ --query publicIps --output tsv \ --resource-group <rgn>[sandbox resource group name]</rgn>) echo $PASSWORD
Connect to the SUSE virtual machine
Now you have a SUSE VM that's ready to install SQL Server. Connect to it by using Secure Shell (SSH):
In the Cloud Shell, run this command.
ssh suseadmin@$IPADDRESS
When asked if you're sure, type yes.
For the password, enter the displayed password from the earlier command, and then press Enter. SSH connects to the VM and shows a bash shell.
Install the SQL Server package
Now install and configure SQL Server. The first task is installation:
To download the Microsoft SLES repository configuration file, run this command:
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo
If you're asked for a password, use the random password.
To refresh your repositories, run this command:
sudo zypper --gpg-auto-import-keys refresh
If any of the SUSE repositories is unavailable, type i, and then press Enter. If you're warned about a repository signed with an unknown key, type yes, and then press Enter.
To install SQL Server, run this command, and type y to confirm:
sudo zypper --no-gpg-checks install -y mssql-server
Configure SQL Server
Before you use SQL Server, you must specify the edition that you want and the system administrator password.
Run the following command:
sudo /opt/mssql/bin/mssql-conf setup
If prompted, enter your password.
To select the Evaluation edition, press 1.
Type Yes to accept the license terms.
For the system administrator password, type Pa$$w0rd, and then press Enter.
Confirm the password.
To confirm that SQL Server 2019 is running, run this command:
systemctl status mssql-server --no-pager
Install SQL Server tools
SQL Server is installed. Now install the administrative tools:
To add the Microsoft SQL Server tools repository to
zypper
, run these commands:sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/prod.repo sudo zypper --gpg-auto-import-keys refresh
If any of the SUSE repositories is unavailable, type i, and then press Enter. If you're warned about a repository signed with an unknown key, type yes.
To install SQL Server command-line tools, run this command:
sudo zypper --no-gpg-checks install -y mssql-tools unixODBC-devel
Type YES to accept the ODBC license terms.
Type YES to accept the license terms.
To add the tools to the
PATH
environment variable, run these commands:echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
Create a database
Now you can use the newly installed sqlcmd
tool to create a database.
To check whether SQL Server is running, run this command:
systemctl status mssql-server --no-pager
If SQL Server isn't active, run this command to start the server:
sudo systemctl start mssql-server
Run the following command to connect to SQL Server:
sqlcmd -S localhost -U sa -P 'Pa$$w0rd'
To create a database, run these commands:
CREATE DATABASE WideWorld1 GO
To verify that the database was created, run these commands:
SELECT name, database_id, create_date FROM sys.databases WHERE name = 'WideWorld1' GO
To exit the
sqlcmd
tool and SSH, run the command exit twice.