How to install and run Microsoft SQL Server and MySQL on Mac

Guide to run Microsoft SQL Server & MySQL on MacPhoto by Mikhail Fesenko on UnsplashIf you’re familiar with SQL Queries, you’d probably know these two software. When it comes to Windows operating system, installing Microsoft SQL Server adn MySQL is…


This content originally appeared on Level Up Coding - Medium and was authored by Randil Tennakoon

Guide to run Microsoft SQL Server & MySQL on Mac

Photo by Mikhail Fesenko on Unsplash

If you’re familiar with SQL Queries, you’d probably know these two software. When it comes to Windows operating system, installing Microsoft SQL Server adn MySQL is pretty much easy. But when you have a Mac as your local workstation, you’d have to take a few more extra steps to get them installed and run properly.

In this article, I explain step by step how you can install both applications on your Mac computer. If you wish, you can follow along with me or if you already know some steps, you can skip them and go to where necessary.

1. How to run Microsoft SQL Server on Mac

In this scenario, we install & run Microsoft SQL Server with the help of Docker.

Step 01:

First, you need to download Docker to your local machine if you don’t have it. Use the below link to download Docker and install it on your local machine.

Docker Desktop for Mac and Windows | Docker

You can verify Docker installation using the command below.

$ docker --version

Step 02:

After that, you need to pull the SQL Server 2019 Linux container image from Microsoft Container Registry. Open the terminal and paste the below command [Make sure docker is running background].

You can find the relevant Docker images from here.

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

Then you can run the docker images command and verify whether the docker image has been pulled successfully.

Step 03:

Then you need to run the above docker container. So that paste the below command in the terminal [Make sure you set your own password for the “SA_PASSWORD=yourStrong(!)Password” field; Your password should contain at least 8 characters including upper case characters, lower case characters, base 10 digits and symbols]

$ docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourStrong(!)Password" -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2019-latest

[Here, you need to add a password for the SA_PASSWORD field and you can name your container after the --name flag. -d flag represents the detach mode that releases the terminal after you run the above command].

Then run the docker ps command to verify whether your container has started to run. If your container stops after a few seconds it started, run docker ps -a command & docker logs <container-id> to check what’re the errors.

Step 04:

Next, you need to install sql-cli via npm. For that use the below command on your terminal [Make sure you have installed npm on your Mac before proceeding].

If you don’t have npm installed on your Mac, go to this link and get npm installed on your Mac.

$ npm install -g sql-cli
OR
$ sudo npm install -g sql-cli

Step 05:

Then you need to start the SQL server. For that, use the below command on your terminal.

$ mssql -u sa -p <yourStrong(!)Password>

If you have configured it correctly up to this point, you should get the mssql> prompt in your terminal.

Then run select @@version to verify the connectivity.

$ mssql -u sa -p yourStrong(!)Password
Connecting to localhost...done
sql-cli version 0.6.2
Enter ".help" for usage hints.
mssql> select @@version
--------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU15) (KB5008996) - 15.0.4198.2 (X64)
Jan 12 2022 22:30:08
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 20.04.3 LTS) <X64>
1 row(s) returned
Executed in 1 ms
mssql>

Step 06:

Next, we need to install a GUI. For that, we use Azure Data Studio. You can download Azure Data Studio via the link below.

Download and install Azure Data Studio - Azure Data Studio

[Make sure you download the relevant file for macOS].

After you download and unzip the software, you will be able to automatically connect to the localhost connection by giving a username & password.

If you didn’t get connected to your localhost connection automatically, try to establish the connectivity manually by giving the server name, username and password. Then you will be able to connect to the local host.

In the Azure Data Studio, window click Create a Connection and enter the following information and click connect.

server -> localhost
username -> sa
password -> yourStrong(!)Password
then click connect
Screenshot by the Author | Azure Data Studio — Create a Connection

If you couldn’t establish a connection even after several tries, do not worry; first, remove the docker container that you created earlier via the docker rm <container id> command and then remove the docker image using the docker rmi <docker-image-name with tag> command. Once you removed everything, start once again from the beginning [Make sure you set a strong password in the docker run command according to the constraints].

Step 07:

Once you get the connectivity via the Azure Data Studio, you can run your SQL queries and get your work down.

Step 08:

Once you completed your work. you can save your workings and quit the workspace and mssql prompt[press ctrl+c] and stop the running Docker container using the docker stop <container-id> command. Once you want to reopen it, restart the existing docker container and start the SQL server via the terminal giving your username and password.

$ mssql -u sa -p yourStrong(!)Password

Then open the Azure Data Studio once again and continue your work.

References:

2. How to run MySQL on Mac

In this scenario, you can execute SQL Queries using MySQL WorkBench & MySQL Community Server on Mac.

Step 01:

First, you need to download two software into your Mac Computer which is MySQL WorkBench & MySQL Community Server to execute SQL queries on your Mac.

Use the below links to download them to your computer.

Step 02:

After you install both software you can establish the SQL connection through MySQL Workbench and execute SQL queries as you prefer.

First, you need to open System Preferences and select MySQL(most probably located at the bottom of the System Preference window). Then click Start MySQL Server. Next, open the MySQL WorkBench and create a new connection with connection name, username and password. Then you will be able to access the MySQL server and run your SQL queries.

Thank you for reading, hope you found the information interesting in this article. If you have any questions regarding setting up the software, please drop me a message.

Happy Learning! 😀


How to install and run Microsoft SQL Server and MySQL on Mac was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Randil Tennakoon


Print Share Comment Cite Upload Translate Updates
APA

Randil Tennakoon | Sciencx (2022-03-24T20:59:33+00:00) How to install and run Microsoft SQL Server and MySQL on Mac. Retrieved from https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/

MLA
" » How to install and run Microsoft SQL Server and MySQL on Mac." Randil Tennakoon | Sciencx - Thursday March 24, 2022, https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/
HARVARD
Randil Tennakoon | Sciencx Thursday March 24, 2022 » How to install and run Microsoft SQL Server and MySQL on Mac., viewed ,<https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/>
VANCOUVER
Randil Tennakoon | Sciencx - » How to install and run Microsoft SQL Server and MySQL on Mac. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/
CHICAGO
" » How to install and run Microsoft SQL Server and MySQL on Mac." Randil Tennakoon | Sciencx - Accessed . https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/
IEEE
" » How to install and run Microsoft SQL Server and MySQL on Mac." Randil Tennakoon | Sciencx [Online]. Available: https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/. [Accessed: ]
rf:citation
» How to install and run Microsoft SQL Server and MySQL on Mac | Randil Tennakoon | Sciencx | https://www.scien.cx/2022/03/24/how-to-install-and-run-microsoft-sql-server-and-mysql-on-mac/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.