Installing MSSQL on MAC

Step 1 – Install MS-SQL on your Mac

Microsoft has made SQL 2017 and later version available for MacOS and Linux system. This change has made possible to run SQL Server from a Docker container. There for no need to install a virtual machine with Windows.

Follow instruction described in below article to install MS-SQL on your Mac.

Step 2 – Connect to SQL Server with SQL Client (dbeaver)

Step 3 – Restore sample database WideWorldImporters  

  1. Copy backup file of WideWorldImporters  https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0
  2. use docker exec to create a backup folder. The following command creates a /var/opt/mssql/backup directory inside the SQL Server container.

sudo docker exec -it MSSQLDB mkdir /var/opt/mssql/backup

  • Use docker cp to copy the backup file into the container in the /var/opt/mssql/backup directory.
  • Use below command in SQL Client to list database files –

restore FILELISTONLY FROM disk = '/var/opt/mssql/backup/WideWorldImporters-Full.bak'

  • Use below command to restore database 

RESTORE DATABASE WideWorldImporters FROM DISK = '/var/opt/mssql/backup/WideWorldImporters-Full.bak' WITH MOVE 'WWI_Primary' TO '/var/opt/mssql/data/WideWorldImporters.mdf', MOVE 'WWI_UserData' TO '/var/opt/mssql/data/WideWorldImporters_userdata.ndf', MOVE 'WWI_Log' TO '/var/opt/mssql/data/WideWorldImporters.ldf', MOVE 'WWI_InMemory_Data_1' TO '/var/opt/mssql/data/WideWorldImporters_InMemory_Data_1'

  •  Run query against database

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s