Table of Contents
We need a database and a database management application to start familiarizing and learning database management with SQL language. There are many famous database types, but using Microsoft SQL Server is the most accessible to begin learning. Although not supported as much as Windows, Mac still has many excellent replacement applications to install SQL Server on Mac and manage databases on Mac, which are Docker and Azure. Now let’s install Lucid Gen.
Virtual machine | SQL Server |
Compatible | ARM và Intel |
Application required | Docker, Azure Data Studio |
Price | Free |
Install SQL Server on Mac using Docker
To create a SQL Server right on Mac, the most recommended tool is Docker. Please do it in turn in the order of the instructions. First, you must check if your Mac is an Intel or Apple M1 chip.
Mac chip Apple M1
According to information from Docker’s manual page, if you are using Mac chip Apple M1 then you need to install Rosetta 2 because some binaries of this application are still Darwin/AMD64.
You click to open the Terminal application available on Mac (use Command-Space to find Terminal) > paste the code below and then Enter > type A to agree to the terms.
softwareupdate --install-rosetta
Download and install Docker
Step 1: Click the button below to download Docker for Mac, and choose the correct version for your Mac.
Step 2: Open the Docker installation file > drag and drop the Docker icon into the Applications folder.
Step 3: You open Docker > go to Settings > Resources > increase Memory to about 4GB. This parameter is neither less nor much, suitable for a simple SQL Server.
Temporarily you hide Docker, and we proceed to install SQL Server according to the instructions below.
Initialize SQL Server (Azure SQL Edge)
Step 1: You open Terminal> paste the code below and Enter> enter the password to open the machine (while typing, it will not display anything, enter it correctly) and Enter.
sudo docker pull mcr.microsoft.com/azure-sql-edge:latest
Step 2: You continue to paste the code below into Terminal and Enter> enter the password to open the machine and Enter.
sudo docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=Password.1' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge
You can change Password.1 to another password you want.
Note: SQL Server password requires the following:
– At least 8 characters.
– Contains lowercase letters, uppercase letters, numbers, and special characters.
If you want to change the password after creating SQL Server, you can use this command in Terminal.
sudo docker exec -it azuresqledge /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P "<Old_Password>" \
-Q 'ALTER LOGIN SA WITH PASSWORD="<New_Password>"'
Step 3: You open Docker > Containers / Apps > make sure there is a SQL Server named azuresqledge running; its status will be RUNNING. If it is off, click the play icon to make it run.
You can pause, restart, and delete SQL Server right in the Docker interface.
That’s it, and you already have a primary SQL Server on your Mac. Now that you can sleep Docker, we will proceed to install Azure to work with this SQL Server.
Install Azure Data Studio on Mac
Azure Data Studio is a portable Microsoft application (no need to install, open and use). It is designed only to work with Microsoft SQL Server or Azure SQL Server; of course, it is perfect. As for other types of databases, many other applications will support them, and you will find out later when you meet them.
Step 1: You download Azure Data Studio for Mac with the button below > download the zip file in the macOS line.
Step 2: Double-click the zip file to extract it > open Azure Data Studio > click Add Connection or Create a connection > enter SQL Server connection information as follows:
- Server: localhost
- Authentication type: SQL login
- User name: sa
- Pass: Password.1
And this is what it looks like to work with SQL Server on Azure Data Studio; now you’re done and ready to learn the SQL language.
Conclusion
There are many applications available for working with databases, not just Microsoft products. Lucid Gen has discovered that in Vietnam, many users prefer Navicat, and I personally find Navicat’s interface quite user-friendly. It also supports several other well-known databases. In the following article, I will guide you on how to install Navicat on your Mac.
I followed the instructions and everything was up and running, but today I got an error – azure data studio now says it requires parallels to run. what can I do?
Hello, please try to restart your Mac or force quit all anything related to Docker in the Activity Monitor. Docker has some problems with the recent version.
Thank you very much. I was stuck in installing SQL on my Mac but this page helped me a lot.
Hello Fateme, congratulation!
Hi! When we try to connect to the SQL Server, many times we get an Error as Provider: Named Pipes Provider, Error: 40 – could not open a connection to SQL server.
Hello, try to restart the SQL sever, search your error on Stackoverflow.