Skip to content

Latest commit

 

History

History
93 lines (55 loc) · 4.34 KB

SDS-DataScienceAZ-P3-MSSQL-Express-setup.md

File metadata and controls

93 lines (55 loc) · 4.34 KB

SuperDataScience: Data Science A-Z course | [email protected] | 2019-11-06

Part-3/Module-17: MS SQL Server Express setup

WHY (to install and run SQL Server as a Docker container)?

  • In case you're not running Windows OS (e.g. MacOS)

Install MS SQL Server Express docker image

  • On console, run:
    docker pull mcr.microsoft.com/mssql/server

Run MS SQL Server Express

  • On console, run:
    docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu

  • or: docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest

  • Check that the container is running OK:
    docker ps -a
    => You should see MS SQL container (with the name you gave with --name parameter) running

  • To map local directory to MSSS container, modify and run this: docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 --name sql1 -v <PATH-TO-YOUR-LOCAL-DIR>:/data -d mcr.microsoft.com/mssql/server:2017-latest
    => Now you can access local files inside the container in /data dir

Connect to MS SQL Server Express container

  • To connect to SQL Server container, run:
    docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>
    => Now you can execute SQL command inside the Container

  • To connect SQL Server container from outside, run:
    sqlcmd -S <ip_address>,1433 -U SA -P "<YourNewStrong@Passw0rd>"
    NOTE: This assumes you have installed sqlcmd tool on your host system

Install sqlcmd and bcp the SQL Server command-line tools on Linux

Use Visual Studio Code to execute SQL Server commands

Install Azure Data Studio

Install Visual Studio

Stop and remove sql SQL Server Express container

  • To stop the container, run:
    docker stop <container name or ID>

  • Remove the container, run:
    docker rm <conyainer name or ID>

More info