MSSQL on Mac
I was inspired to write this simple blog after reading the Microsoft Migrate a SQL Server database from Windows to Linux using backup and restore.This article about how to restore the AdventureWork on Linux, but this blog about MSSQL server 2017 on Mac OS Sierra.
MSSQL available as a docker image to install on Mac. If you have Docker installed in your Mac, simple to install with two commands as shown in the http://aka.ms/sqldev site:
docker pull microsoft/mssql-server-linux
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
After the docker installation, login to the doker:
docker exec -i -t <CONTAINER ID> /bin/bash
Create a new folder “backup” in the “/var/opt/mssql”. If you are not admin run the command sudo su to login as super user.
cd /var/opt/mssql/
mkdir backup
Your work as admin in the docker is finished. Download the AdventureWork from https://msftdbprodsamples.codeplex.com/downloads/get/880661 to your local machine and unzip. Then copy to Docker instance
docker cp AdventureWorks2014.bak <CONTAINER ID>:/var/opt/mssql/backup
If you don’t have sqlcmd installed in your host machine follow the article to install :
brew install mssql-tools
In your host machine use the sqlcmd tool to login to the MSSQL server:
sqlcmd -S 127.0.0.1 -U SA -P 'yourStrong(!)Password'
Following the link https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-migrate-restore-database
Restore the backup file:
RESTORE DATABASE AdventureWorks
FROM DISK = '/var/opt/mssql/backup/AdventureWorks2014.bak'
WITH MOVE 'AdventureWorks2014_Data' TO '/var/opt/mssql/data/AdventureWorks2014_Data.mdf',
MOVE 'AdventureWorks2014_Log' TO '/var/opt/mssql/data/AdventureWorks2014_Log.ldf'
GO
Now you are ready to go. I am using Visual Studio Code and the mssql plugin to access this database.
Comments
Post a Comment
commented your blog