(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.)
I am on Windows so SQL server management studio works fine for me. However, my application is hosted and my client needs to make some entries in DB and he has Mac. SQL Server Management Studio by Microsoft Corporation is a program that was designed for configuring, managing and administrating SQL Server databases. Since SQL Server Management Studio for Mac cannot be found, you may give these applications a try instead.
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
My team members uses windows so they used for our project's Database microsoft sql server management studio but I cannot download the SSMS since it is not compatiple with mac. So you want to customize your SQL Server Management Studio – SQLJosh September 11, 2018 5:23 am There has been many a blog post out there that shows you some of the great ways you can customize the look and feel of your management studio windows. Microsoft SQL Server. The equivalent of Microsofts SQL Management Studio. 30 day trial and it’s by far the best tool available for SQL Server on Mac.
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:
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’
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’,
MOVE ‘AdventureWorks2014_Log’ TO ‘/var/opt/mssql/data/Adventureworks2014.ldf’
Microsoft Sql Server Management Studio For Mac
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.
What Is Sql Server Management Studio
When you are finished with your work in your Docker Container, you can stop the Container with the following command:
docker stop sql2019_ctp2
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
Sql Tutorial
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
- Advertisement
- Navicat for SQL Server for Mac OS v.9.1An ideal solution for administration and development which lets you create, edit databases, run SQL queries and connect to remote SQLServer in an easier way. It features an intuitive GUI and offers powerful visual tools such as Query Editor with ...
- Devart ODBC Driver for SQL Server v.1.1Devart ODBC Driver for SQLServer provides high-performance and feature-rich connectivity solution for ODBC-based applications to access SQLServer databases from Windows, Linux, MacOS, both 32-bit and 64-bit.
- Actual ODBC Driver for SQL Server v.2.6The Actual SQLServer ODBC Driver lets you access your companys Microsoft SQLServer database from within Microsoft Excel. You can connect to any database you are authorized to use, and work with the data just like your Windows-using co-workers. All ...
- PHP SQL Server (MSSQL) Query Analyzer v.0.43Web based tool written in PHP by Luiz Miguel Axcar to build and run queries on a remote or local MSSQL (Microsoft SQLServer). Support for SQL code highlight (!!!), table browser, field browser, TOP records, most used tables, CSV results export, ...
- JTDS - SQL Server and Sybase JDBC driver v.1.0Open source JDBC 3.0 type 4 driver for Microsoft SQLServer (6.5 up to 2012) and Sybase ASE. jTDS is a complete implementation of the JDBC 3.0 spec and the fastest JDBC driver for MS SQLServer. For more information see http://jtds.sourceforge.net/ ...
- MyDBR Web Reporting v.3. 3. 2000myDBR is an innovative web reporting solution for MySQL and Microsoft SQLServer with support for latest smartphones (Android, iPhone, and Symbian). myDBR reporting solution brings unparalleled speed of authoring even the most complex reports. By ...
- Ranet OLAP v.3.1.741Library of components Ranet.UILibrary.OLAP is intended for creation of full-featured Internet applications (RIA, Rich Internet Application) by business analysts based on platform Microsoft SQLServer Analysis Services.
- PHPico Web Server v.0.1PHPico Web Server 0.1 provides you with a powerful servermanagement tool which is stand alone, single threaded and all code is load only once. The server do only handle the incoming and outgoing HTTP requests, and sets up the super global variables.
- PHP MSSQL Server Admin - Query Analyzer v.0.43Web based tool written in PHP by Luiz Miguel Axcar to build and run queries on a remote or local MSSQL (Microsoft SQLServer). Support for SQL code highlight (!), table browser, field browser, TOP records, most used tables, CSV results export, etc. ...
- Virtual Ticket Developer Professional v.2010Develop team productivity & project management apps.
- DB Solo v.3.0DB Solo is a powerful database development and management tool for developers and DBAs. DB Solo has an intuitive user interface that allows you to explore and manage your database objects as well as execute your own ad-hoc queries. DB Solo supports ...
- DB Solo for Mac OS v.3.8.2A cross-platform database development and management tool for developers and admins. DB Solo supports all major DBMS products available today, including Oracle, SQLServer 2000 and 2005, DB2, Sybase, H2, Postgres, MySQL and Solid.Key Features ...
- SourceAnywhere Standalone v.3.0.1SourceAnywhere Standalone is SQLserver-based version control software with seamless integration with Visual Studio, Eclipse, and other IDEs, cross-platform support, and unique caching mechanism for remote performance. SourceAnywhere Standalone ...
- MyInfoTool v.0.92rc1myInfoTool is a PHP driven, file based database and database management system. You do not need any SQLserver like mySQL. myInfoTool is a god choice for small sites without SQL support. Examples for use: news, guestbooks, FAQ...
- RazorSQL for Mac v.8.3.6SQL editor, database query tool, database browser, and db admin tool. Visually create, edit, alter, drop, and view objects as well as import and export data. Browse objects with the database browser. Supports over 40 databases.
- Apache AxKitApache AxKit is a convenient servermanagement tool which is used for Apache. It provides on-the-fly conversion from XML to any format, such as HTML, WAP or text using either W3C standard techniques, or flexible custom code. AxKit also uses a ...
- FmPro Migrator v.5.98FmPro Migrator quickly and accurately migrates FileMaker Pro database structure and data to MySQL, Oracle, Access, SQLServer, Sybase, DB2, OpenBase, PostgreSQL, FrontBase, SQLite and Valentina. -- Converts Access Forms/Reports, Relationships, Value ...
- SQLAPI++ for Mac OS X v.3.8.2.0SQLAPI++ is a library designed to enable you to access multiple SQL databases (Oracle, SQLServer, DB2, Sybase, InterBase, Informix, SQLBase, MySQL, PostgreSQL and ODBC, SQLite). It uses native APIs of target DBMS so applications developed with ...
- Izenda Ad Hoc - Express Edition v.4.0Izenda Ad Hoc - Agile Business Intelligence for ASP.NETLiberate Your Organization's Relational Data Today!Izenda Ad Hoc empowers business users to directly explore relational data from a web browser. * Intuitive and Completely Web-Based AJAX Report ...
- Consideo Process Modeler for Mac OS v.6.0.2An enhancement of the successful Consideo Modeler. It’s the first easy to use tool to run scenarios (System Dynamics) on constraints (ToC) and the critical chain of processes and projects. Connect to MS-Project, Excel or SQL, create management ...
- PhotoUpLink for iPhoto for Mac OS An iPhoto export plugin that allows users to send images and
- Devart ODBC Driver for SQL Server Devart ODBC Driver for SQL Server provides
- Izenda Ad Hoc - Express Edition Izenda Ad Hoc - Agile Business Intelligence for
- Consideo Process Modeler for Mac OS An enhancement of the successful Consideo Modeler. It’s
- Ranet OLAP Library of components Ranet.UILibrary.OLAP is intended for
- Valentina Studio Pro for Mac OS Fast and powerful visual SQL database creation,
- ByteDesigner ByteDesigner is the emerging enterprise tool for designing
- PHPico Web Server PHPico Web Server 0.1 provides you with a powerful server
- Virtual Ticket Developer Professional Develop team productivity & project management apps.
- MyDBR Web Reporting myDBR is an innovative web reporting solution for MySQL and