Blog Post

Connect SQL Server on Linux using Bash on Ubuntu on Windows


Since Microsoft has launched SQL Server on Linux, you would be working on both the platforms Linux and Windows. You can now add Bash shell on Windows 10 to play with SQL Server on Linux instead of using any third party tool like Putty or other SSH clients.

Connected SQL Server on Linux using Bash on Ubuntu on Windows10

Note: Bash/WSL is still in “beta” version. It is NOT recommended to use in production environment.

Steps to install Bash on Ubuntu on Windows 10

Before trying to install the Bash shell on Windows 10, you need to make sure that the machine is a 64-bit version of Windows 10 Anniversary Update or later (build 1607+).

  • Once you’re sure that you’re using the correct version of Windows 10, open the Settings app> click on Update & security> click on For Developers> under “Use developer features”, select the “Developer mode” option to setup the environment to install Bash.

  • Once you select the “Developer mode”, it will prompt you a message box to turn on the developer mode. Click Yes to enable it after that it will be installing necessary components and will prompt to restart your computer.

  • Once the system is restarted, open Control Panel> click on Programs> go to under “Programs and Feature” and click on the “Turn Windows features on or off”> after that Check the Windows Subsystem for Linux (beta) option and click “OK”

  • It will install “Windows Subsystem for Linux” after that it will prompt you to restart the system, click the Restart now button to complete the task.
  • After the restart, click on the Windows start button & type “bash”, and run the bash as administrator.

  • The first time when you run the bash.exe file, it will prompt to accept the terms of service. Once you type “y” to continue,it will download the “Bash on Ubuntu on Windows” application from the Windows Store. It will also ask to create a user account and password for use in the bash environment.

  • Click on the Windows start button again and type “Bash”, you will get option “Bash on Ubuntu on Windows”. Once you click that, it open the bash console

  •  Type the below syntax to connect to you Linux machine using IP

Syntax: ssh <Linux Machine IP>

  • After connecting to Linux machine, switch to root user and connect to SQL Server on Linux using SQLCMD tool. If you have not installed the SQLCMD tool, you can follow the link –  Install SQL Server Tools on Ubuntu

Syntax: sqlcmd -S <hostname> -U <username> -P <password>

Do you find the “Bash on Ubuntu on Windows” console very handy to connect your SQL Server on Linux machine?

The post Connect SQL Server on Linux using Bash on Ubuntu on Windows appeared first on .


You rated this post out of 5. Change rating




You rated this post out of 5. Change rating