Check my post on installing SQL Server in Red Hat Linux.
As we try to access the server outside of the network, we ought to configure a setting in firewall.
All the below steps applicable for Azure Virtual Machine with Linux installed on it.
Follow the below steps
Add TCP inbound rule in Linux
Run the bellow command in PuTTY Tool. Check my post to know how to use PuTTY tool to access Linux machine via SSH.
sudo firewall-cmd –zone=public –add-port=1433/tcp –permanent
sudo firewall-cmd –reload
Configure DNS in Azure Portal
It can be easily configured in the portal, check how to configure DNS in Azure.
Add TCP inbound in Portal
Again, this should be configured in network Security group inbound rule.
Once the above steps are successfully done, then can access the SQL Server in local SQL Server Management Studio or any machine.
Pass the following details to connect in SSMS.
Server: XXXX.southeastasia.cloudapp.azure.com. Here XXX denotes the DNS name which you configured in Portal.
In Linux, when we install SQL Server it will ask for SA account setup so now we can use SA account to login.
This post explains you in detail (step by step) about how to install SQL Server and SQL CMD tools in Red Hat Enterprise Linux 7.2.
Azure Virtual Machine Template “SQL Server vNext on Red Hat Enterprise Linux 7.2” has been used for this demo.
Go to Azure Virtual Machine and click “Add”, it will open a window where you can choose the SQL Server vNext on Linux template.
Check the information on the below page as it has the command to configure and start SQL Server.
Configure the VM as usual, check the “Authentication type”. It has two options. I am going to choose Password for this demo.
Fill the other details and create a virtual machine.
It will take some time to configure the Linux machine. Once the deployment is done, then you can access the machine.
Since this is Linux machine, Azure gave us a connection IP address. I am using “PuTTY” (command line tool) to access this machine.
Download and install the PuTTY Software from here.
Once installed PuTTY, open and pass the IP address and click Open. You can save the host as new session and can load and open for next time.
Login with the username and password that you defined while creating the virtual machine.
Enter the below command to install and configure SQL Server.
It will ask password to proceed further and also need to confirm the license.
Next step is to set up the SA admin password for SQL Server. Setup will be completed after this step.
Check the status of the service.
systemctl status mssql-server
As we need to run the SQL scripts in command line, we need to install the SQL CMD tools. To install, you need to go to the root directory.
#Install SQL Cmd tools
Run the below commands to get the file and exit from root.
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
Run the below command to install
sudo yum install mssql-tools
Once the tool is successfully installed. You can see the success message.
Open command to start type the SQL commands.
Pass the SA credentials. We are going to access with SQL Server authentication mode.
sqlcmd -S localhost -U SA –P ‘SA Password’
Type the SQL Script and end with GO.