Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

How to run mssql/sql server on Mac

Are you looking to run microsoft sql server on Mac? Then you are at the right place.

I am going to tell you how you can run sql server easily in few minutes.

  • First you need to install docker on your system. You can use below link to download the docker on your mac system.  https://www.docker.com/products/docker-desktop
  • Click on Mac with intel chip or if you have mac with apple chip.
  • Once it is downloaded ,run it and install it.
  • After installation docker will be start automatically or if it is not start then you can start it manually by searching it in launcher.
  • Open your terminal to check if installation happen correctly. Run below command
  •  Docker -v
  • this command will give you docker version like below:
Docker version 20.10.7, build f0df440

Now run below commands in terminal:


docker pull mcr.microsoft.com/mssql/server:2019-latest

Output:

2019-latest: Pulling from mssql/server

a31c79f4ad: Pull complete 

a039b99d1e: Pull complete 

1d60c7fae0: Pull complete 

b927883ade: Pull complete 

120d687cdd: Pull complete 

Digest: sha256:3a64da47fb2c8b4d730856b06930999af7ed4eab2d540fae2c7063da7a4fd

Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2019-latest

mcr.microsoft.com/mssql/server:2019-latest


Once everything is downloaded run below command, It will run image in container:


docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Test123" -p 1433:1433 --name sqltest -h sqltest -d mcr.microsoft.com/mssql/server:2019-latest

Output:

842bb946ac6d35bb15e232e526685e416


docker ps


above command will display running containers

Congrats! You have started your container.




Note: If you are on Mac M1 then download the Azure SQL Edge image because that has been ported on ARM64 architecture and follow below commands.

docker pull mcr.microsoft.com/azure-sql-edge


Now run the below command

docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=Test@123' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge


Now open Visual studio. If you don't have visual studio then you can follow the below link:

Now install it and open it and download mssql extension by microsoft like below:



Once extension is installed you can click on extension on left side for sql server connection on vscode.
2nd last icon is mssql on left side.



Click on it and pass values like 

  • Server: localhost,1433
  • Database(optional) hit enter
  • login: select sql login
  • user : sa (which was given in command)
  • password: test (which was given in command)
  • hit enter and profile will be created.
Now you are connected with SQL server.  You can see on your top left side under connections. 
Right click on localhost or servername and click on new query.

In the query window type select 1; and run this select.

We have successfully running sql server on docker and we have just executed one query on sql server.

Conclusion

Running SQL Server on docker can be a good idea when you don't want to install anything on your local system. Since we don't have any setup of SQL Server for mac , running it with docker can be a good thing.

Note: If you think this helped you and you want to learn more stuff on devops, then I would recommend joining the Kodecloud devops course and go for the complete certification path by clicking this link

Quantum Computing: The Future of Supercomputing Explained

  Introduction Quantum computing is revolutionizing the way we solve complex problems that classical computers struggle with. Unlike tradi...