Sql Server For Mac
Build intelligent, mission-critical applications using a scalable, hybrid data platform for demanding workloads. Get started with a 180-day free trial of SQL Server 2017 on Windows. Take advantage of the built-in high availability, security, and intelligence of Azure SQL Database, and use the. Excel 2016 for Mac SQL Server ODBC issues with connecting to SQL Server I am having trouble connecting to a SQL Server via the new Excel 2016 for Mac SQL Server ODBC New Database Query feature. I tried to follow the Office Support info available on this link. Microsoft's documentation: Run the SQL Server Docker image on Linux, Mac, or Windows. Share: Twitter Facebook LinkedIn. About David Neal. David is a family man, musician, illustrator, software developer, and Microsoft MVP living in North GA. He runs on a high-octane mixture of caffeine and JavaScript, and is made entirely of bacon. SQL Server Management Studio is not available for Mac but there are plenty of alternatives that runs on macOS with similar functionality. The most popular Mac alternative is DBeaver, which is both free and Open Source. If that doesn't suit you, our users have ranked 29 alternatives to SQL Server Management Studio and 15 are available for Mac so hopefully you can find a suitable replacement. Hi Are there plans for a SSMS to run on Mac OSX, since there is a Visual Studio for Mac? Thanks davej Hello, The SSMS team has no plan at this time to move SSMS to be cross.
(Be sure to checkout the FREE SQLpassion Performance Tuning Training Plan - you get a weekly email packed with all the essential knowledge you need to know about performance tuning on SQL Server.)Years ago when I switched from Windows to Mac, people have told me regularily that I’m crazy. How can I be that stupid to work on MacOS when I’m dependent on SQL Server? In my case it wasn’t that terrible, because my main work is about content creation (writing blog postings, articles, presentations, training videos) and very often I was only connecting through a RDP connection to a remote SQL Server. Therefore running natively on MacOS was not a big deal for me, and for the last resort I always have a Windows VM which runs in VMware Fusion on my Mac.
But since the introduction of the Container concept through Docker and the possibility to run SQL Server directly in a Container, my life was changing even better. Because now I can run SQL Server 2017+ directly on my Mac and I even don’t really need a Windows VM anymore. In this blog posting I want to show you how you can do the same and run SQL Server directly on your Mac in a Docker container.
Installing SQL Server in a Docker Container
Before you can install SQL Server in a Docker Container on the Mac, you have to install and configure of course Docker itself. I don’t want to go into the details how to install Docker itself, because the necessary steps are very well documented.
Before you can create a Docker Container for SQL Server, you have to pull the correct Docker Image from the Docker Registry. In my case I have decided to try out the latest CTP version of SQL Server 2019:
docker pull mcr.microsoft.com/mssql/server:2019-CTP2.1-ubuntu
When you have pulled the image, you can see it with the docker images command in your Terminal:
You can think about a Docker Image like an ISO file: it’s just an image, and you can’t run it directly, because you have to install it. Therefore we also have to “install” the pulled Docker Image. In Docker you can “install” an image by running it. And that creates the actual Docker Container, which is finally the exectuable that you are executing. Let’s run our Docker Image with the docker run command:
Microsoft Sql Server For Mac
docker run -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=passw0rd1!’ -p 1433:1433 –name sql2019_ctp2 -d mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu
As you can see from the command line, you have to pass in a lot of different parameters. Let’s have a more detailed look on them:
- -e ‘ACCEPT_EULA=Y’
- With the -e option you set an environment variable, on which SQL Server is dependent on. In our case we have to accept the EULA to be able to use SQL Server.
- -e ‘SA_PASSWORD=passw0rd1!‘
- With the SA_PASSWORD environment variable we set the password for the SA login.
- -p 1433:1433
- With the -p option we bind a port on our host machine (in my case on the Mac) to a port in the Container. The port on the left side of the colon is the port on the host machine, and the port on the right side of the colon is the port in the Container. In my case I bind the default SQL Server port of 1433 within the Container to the port 1433 on my Mac.
- Therefore I can directly access the exposed SQL Server Container through the IP address of my Mac on the network. If you have multiple SQL Server Containers, you can also bind them to different ports on your host machine to access them independently from each other.
- –name
- With the –name option we assign a custom name to our Docker Container.
- -d
- And with the -d option we specify the Docker Image that we have pulled previously, and that you want to run the Docker Container detached from the Terminal. This just means that you can close your Terminal, and your Docker Container is still running in the background.
After you have executed that Docker command, your Docker Container is up and running.
Accessing SQL Server on a Mac
We have now 2019 up and running in a Docker Container. But how do we access SQL Server? Of course, I can start up a Windows VM, and use SQL Server Management Studio to access SQL Server. But then I’m again dependent on a Windows VM, which also needs periodically updates, and it would be also a huge overhead to deploy a whole Windows VM just for SQL Server Management Studio…
Therefore let’s introduce Azure Data Studio! Azure Data Studio was formerly known as SQL Operations Studio and it is a client application with which you can manage SQL Server – natively on Windows, Linux, and Mac!!!
As you can see from the previous picture, I have connected here directly to localhost, because in the last step we have exposed the port 1433 of the Docker Container to our host machine. Don’t get me wrong: compared to SQL Server Management Studio, Azure Data Studio is “nice” but… 😉
But hey, I can run it directly on my Mac (without the need of a Windows VM), I can run SQL statements, I have access to Estimated and Actual Execution Plans, and very importantly – it’s extensible. What do I need more? For the kind of work that I’m doing, it’s enough.
Restoring your first Database
When you look back to the previous picture, you can see that you got a vanilla installation of SQL Server 2019. There are our system databases, the crazy default settings, and that’s it. There are of course currently no other database. So you have to create your own databases, or you take an existing database (maybe from a Windows-based SQL Server installation) and you restore it in your Docker Container. Let’s do that now.
In my case I want to show you now the necessary steps how to restore AdventureWorks in the Docker Container. First of all you have to copy your backup file into the Docker Container. But you can’t do a regular cp command from the Terminal, because that command has no idea about your Docker Container. Makes somehow sense…
Therefore your Docker installation offers you the command cp with which you can copy a local file into a Docker Container and vice versa. Let’s take now our backup of AdventureWorks and copy it into the folder /var/backups of our Docker Container:
docker cp AdventureWorks2014.bak sql2019_ctp2:/var/backups/AdventureWorks2014.bak
After you have copied the backup file, we can now restore the database. But the destination folders are different as on a Windows-based SQL Server installation, therefore we also have to move our data and log files. Therefore I have executed in the first step the following command to get the logical file names of our database backup.
RESTORE FILELISTONLY FROM DISK = ‘/var/backups/AdventureWorks2014.bak’
Sql Server Management Studio For Mac
And based on that information, let’s perform now the restore of our database.
RESTORE DATABASE AdventureWorks2014 FROM DISK = ‘/var/backups/AdventureWorks2014.bak’
WITH
MOVE ‘AdventureWorks2014_Data’ TO ‘/var/opt/mssql/data/Adventureworks2014.mdf’,
External dvd drive for mac air. MOVE ‘AdventureWorks2014_Log’ TO ‘/var/opt/mssql/data/Adventureworks2014.ldf’
As you can see I’m moving the data and log files into the folder /var/opt/mssql/data. And now we have our AdventureWorks database restored in our Docker Container.
When you are finished with your work in your Docker Container, you can stop the Container with the following command:
docker stop sql2019_ctp2
Sql Server Express On Mac
And with a docker start command, you can restart your Container again:
docker start sql2019_ctp2
In that case, all the changes that you have done in your Docker Container (like restoring the AdventureWorks database), are persisted across restarts.
Summary
Running SQL Server natively on a Mac or on Linux was always a huge April fool. But with the introduction of Docker, and the SQL Server support for it, it’s now real. You can now run natively SQL Server on the Mac, and with the help of Azure Data Studio you can even access SQL Server with a native MacOS application. We have really exiting times ahead of us!
Thanks for your time,
-Klaus
Macally Backlit Mechanical Keyboard for Mac - USB Wired Full Size - Compatible with Apple Mac Mini, Mac Pro, iMac, iMac Pro, MacBook Pro Air - Brown Switches. 4.2 out of 5 stars 10. 99 $129.99 $129.99. Get it as soon as Tue, Oct 15. FREE Shipping by Amazon. Best mechanical keyboard for typing.
Here I’ll show you how to get SQL Server up and running on your Mac in less than half an hour. And the best part is, you’ll have SQL Server running locally without needing any virtualization software.
Prior to SQL Server 2017, if you wanted to run SQL Server on your Mac, you first had to create a virtual machine (using VirtualBox, Parallels Desktop, VMware Fusion, or Bootcamp), then install Windows onto that VM, then finally SQL Server. This is still a valid option depending on your requirements (here’s how to install SQL Server on a Mac with VirtualBox if you’d like to try that method).
Starting with SQL Server 2017, you can now install SQL Server directly on to a Linux machine. And because macOS is Unix based (and Linux is Unix based), you can run SQL Server for Linux on your Mac. The way to do this is to run SQL Server on Docker.
So let’s go ahead and install Docker. Then we’ll download and install SQL Server.
Install Docker
Download the (free) Docker Community Edition for Mac (unless you’ve already got it installed on your system). This will enable you to run SQL Server from within a Docker container.
To download, visit the Docker CE for Mac download page and click Get Docker.
To install, double-click on the .dmg file and then drag the Docker.app icon to your Application folder.
What is Docker?
Docker is a platform that enables software to run in its own isolated environment. SQL Server (from 2017) can be run on Docker in its own isolated container. Once Docker is installed, you simply download — or “pull” — the SQL Server on Linux Docker Image to your Mac, then run it as a Docker container. This container is an isolated environment that contains everything SQL Server needs to run.
Launch Docker
Launch Docker the same way you’d launch any other application (eg, via the Applications folder, the Launchpad, etc).
When you open Docker, you might be prompted for your password so that Docker can install its networking components and links to the Docker apps. Go ahead and provide your password, as Docker needs this to run.
Increase the Memory
By default, Docker will have 2GB of memory allocated to it. SQL Server needs at least 3.25GB. To be safe, increase it to 4GB if you can.
To do this:
- Select Preferences from the little Docker icon in the top menu
- Slide the memory slider up to at least 4GB
- Click Apply & Restart
Download SQL Server
Now that Docker is installed and its memory has been increased, we can download and install SQL Server for Linux.
Open a Terminal window and run the following command:*
This downloads the latest SQL Server for Linux Docker image to your computer.
* The exact command will depend on which release you download. Also, since I wrote this article, Docker has moved the repository for SQL Server. You might need to use
docker pull mcr.microsoft.com/mssql/server:2017-latest-ubuntu
to download SQL Server 2017.Also, SQL Server 2019 Preview has been available since late 2018. As of late 2019 you can download it at
docker pull mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu
.For the latest image, see the official Microsoft repository on the Docker website.
Launch the Docker Image
Run the following command to launch an instance of the Docker image you just downloaded:
But of course, use your own name and password. Also, if you downloaded a different Docker image, replace
microsoft/mssql-server-linux
with the one you downloaded.Here’s an explanation of the parameters:
-d
- This optional parameter launches the Docker container in daemon mode. This means that it runs in the background and doesn’t need its own Terminal window open. You can omit this parameter to have the container run in its own Terminal window.
--name sql_server_demo
- Another optional parameter. This parameter allows you to name the container. This can be handy when stopping and starting your container from the Terminal.
-e 'ACCEPT_EULA=Y'
- The
Y
shows that you agree with the EULA (End User Licence Agreement). This is required in order to have SQL Server for Linux run on your Mac. -e 'SA_PASSWORD=reallyStrongPwd123'
- Required parameter that sets the
sa
database password. -p 1433:1433
- This maps the local port 1433 to port 1433 on the container. This is the default TCP port that SQL Server uses to listen for connections.
microsoft/mssql-server-linux
- This tells Docker which image to use. If you downloaded a different one, use it instead.
Password Strength
If you get the following error at this step, try again, but with a stronger password.
I received this error when using
reallyStrongPwd
as the password (but of course, it’s not a really strong password!). I was able to overcome this by adding some numbers to the end. However, if it wasn’t just a demo I’d definitely make it stronger than a few dictionary words and numbers.Check the Docker container (optional)
You can type the following command to check that the Docker container is running.
If it’s up and running, it should return something like this:
Install sql-cli (unless already installed)
Run the following command to install the sql-cli command line tool. This tool allows you to run queries and other commands against your SQL Server instance.
This assumes you have NodeJs installed. If you don’t, download it from Nodejs.org first. Installing NodeJs will automatically install npm which is what we use in this command to install sql-cli.
Permissions Error?
If you get an error, and part of it reads something like
Please try running this command again as root/Administrator
, try again, but this time prependsudo
to your command:Connect to SQL Server
Now that sql-cli is installed, we can start working with SQL Server via the Terminal window on our Mac.
Connect to SQL Server using the
mssql
command, followed by the username and password parameters.You should see something like this:
This means you’ve successfully connected to your instance of SQL Server.
Run a Quick Test
Run a quick test to check that SQL Server is up and running and you can query it.
For example, you can run the following command to see which version of SQL Server your running:
If it’s running, you should see something like this (but of course, this will depend on which version you’re running):
If you see a message like this, congratulations — SQL Server is now up and running on your Mac!
A SQL Server GUI for your Mac – Azure Data Studio
Azure Data Studio (formerly SQL Operations Studio) is a free GUI management tool that you can use to manage SQL Server on your Mac. You can use it to create and manage databases, write queries, backup and restore databases, and more.
Azure Data Studio is available on Windows, Mac and Linux.
Here are some articles/tutorials I’ve written for Azure Data Studio:
Another Free SQL Server GUI – DBeaver
Another SQL Server GUI tool that you can use on your Mac (and Windows/Linux/Solaris) is DBeaver.
DBeaver is a free, open source database management tool that can be used on most database management systems (such as MySQL, PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, Microsoft Access, Teradata, Firebird, Derby, and more).
DBeaver using the “Dark” theme.
I wrote a little introduction to DBeaver, or you can go straight to the DBeaver download page and try it out with your new SQL Server installation.
Limitations of SQL Server for Linux/Mac
SQL Server 2017 for Linux does have some limitations (at least, in its initial release). The Linux release doesn’t include many of the extra services that are available in the Windows release, such as Analysis Services, Reporting Services, etc. Here’s a list of what’s available and what’s not on SQL Server 2017 for Linux.
Another limitation is that SQL Server Management Studio is not available on Mac or Linux. SSMS a full-blown GUI management for SQL Server, and it provides many more features than Azure Data Studio and DBeaver (at least at the time of writing). You can still use SSMS on a Windows machine to connect to SQL Server on a Linux or Mac machine, but you just can’t install it locally on the Linux or Mac machine.
If you need any of the features not supported in SQL Server for Linux, you’ll need SQL Server for Windows. However, you can still run SQL Server for Windows on your Mac by using virtualization software. Here’s how to install SQL Server for Windows on a Mac using VirtualBox.