Following are some ways to connect to sql server on linux from windows and linux:
Ways Of Connecting To Sql Server On Linux, Putty, Ssms, Or Sqlcmd Tool
Prerequisites:
--ipaddress of linux system
--active sql server services
Modes of connection:
--Existing linux machine with sqlcmd tools
--using putty from windows machine
--using SSMS from windows
Check SQL server services:
#systemctl status mssql-server
#get ip address
#ifconfig
Install sqlcmd SQL Server command-line tools on Linux
To use sqlcmd tool you need to install package:
Use this link to get the required package, choose the latest version.
Open the terminal and locate to downloads directory:
Install the package:
#rpm-ivh mssqltools
If you get any dependencies error when installing package go here
After installationAdd /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
Check if SQLCMD is installed or not:
Run sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P). In this tutorial, you are connecting locally, so the server name is localhost. The user name is SA and the password is the one you provided for the SA account during setup.
Using Putty tools on Windows to connect to SQL Server on Linux
PuTTY is open source software that is available.
Download putty:
Get ip address of linux where sql server is instlled
#ifconfig
Configure putty:
Port 22 is for SSH which is typically used to log into a remote machine and execute commands
Press Yes to security alert:
Give your credentials that used to login your linux system:
Check the sql server ?services
#systemctl status mssql-server.service
Connect to sql server
#sqlcmd -S localhost -U SA -P ‘password’
Using SSMS on Windows to Connect SQL Server on Linux
Through SSMS:
Get ip address and Connect using SA or another login account and password:
Check Server Properties:
Querying and checking version, locations of database files: