I made a map to help identity Sinclair-owned news stations near you.Read More
Never did I think that I'd be able to run SQL Server on my Mac. My, how times have changed.
For the first time, SQL Server 2017 allows users to install the product on Linux. This opens the doors for working with fully-featured SQL Server database engines on MacOS through freely distributable Docker containers. With the addition of a new graphical user interface that's in public preview, Mac users can now leverage the same industry-leading database platform that has previously only been available to Windows users, all on their local computer. Let me show you how to get started in three easy steps.
1. Install Docker
The first step is to install Docker. Start at https://store.docker.com/editions/community/docker-ce-desktop-mac, and click the Get Docker button on the top right. That will download a disc image containing the application. Drag Docker.app into your Applications folder and give it a double-click to launch. Look for the Docker icon in the top menu bar. When the animation stops, Docker is ready to go. Step one: done.
2. Pull the SQL Server 2017 container
Next, start up Terminal.app. This is where you'll issue commands to Docker. Microsoft provides pre-configured images that include the Developer edition of SQL Server 2017 running on Ubuntu Linux. You can pull the most recent version with the following command.
sudo docker pull microsoft/mssql-server-linux:2017-latest
After supplying your MacOS Administrator password, the image is downloaded.
Docker images need to be unpacked into containers, and a single image can be used to create as many identical containers as you'd like; just be sure to give them unique names. The following command will create a single container called 'sqlserver1' from the image you just downloaded. A couple of points:
- Note that you'll want to provide your own strong password for the SQL Server System Administrator account. Just replace "YourStrong!Passw0rd" with something better.
- Port 1401 on the local computer will be forwarded to SQL Server's default listening port of 1433 inside the container. This will be important to remember later.
- Make sure that you forward a different port to 1433 if you decide to create additional containers.
sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=YourStrong!Passw0rd' -p 1401:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest
To verify that everything is working as intended, you can check the status of Docker's containers.
docker ps -a
You should see a line for the container and, hopefully, a status of "up." If you see "exited" here, go back and double check the previous commands were typed correctly. You can also try "docker stop sqlserver1" followed by "docker start sqlserver1" to reset the server. With the container now running, you're done with step two.
3. Install SQL Operations Studio
Microsoft is in the beginning stages of developing a cross-platform graphical user interface for SQL Server called SQL Operations Studio. Though it's still in an early public preview, SQL Ops Studio is already showing promise as a robust, lightweight interface that brings the best of SQL Server Management Studio (a venerable workhorse, but sadly Windows-only) over to the Mac and Linux platforms. The Ops Studio GitHub page will be your source of information as the project progresses. Head over to the GitHub repository, scroll down to the first section of the readme and download the MacOS zip containing the latest stable preview.
Upon Operations Studio's first launch, the Connection window will automatically prompt you for login credentials. Use "localhost" as the name of the server, "SA" as the user name, and fill in the password that you established when the Docker container was created. Then press the Advanced button, and scroll through the properties list until you get to the General section. Fill in the port number of 1401 here, or whichever port you're passing to SQL Server's 1433 listening port. Press OK, then Connect.
That should connect, and pass you back to the main interface. If you've ever seen Visual Studio Code, then you'll instantly recognize the interface's clean and well-organized layout. On the left is a listing of servers you're connected to. Expand the server folder to explore databases, security items and so on.
You're now up and running with the SQL Server database engine running in a Docker container, and you can manage it with Operations Studio on your Mac!
Bonus step 4. Start working with your new SQL Database Engine
What good is a server without a database? Right-click the Databases folder, and choose New Query. In the SQLQuery1 tab, type in the following command.
CREATE DATABASE MyDatabase; GO
Press the Run button to create your first database, which you should see pop up under the Databases folder. You might need to right-click the databases folder and choose Refresh if it doesn't show up immediately.
Operations Studio has a great feature called Snippets that help you quickly write common T-SQL commands. Clear out the CREATE DATABASE statement and change the Connection drop-down at the top to MyDatabase. Type "sql" to see the list of included snippets presented in the IntelliSense popup box.
Arrow down to sqlCreateTable and press Return. Operations Studio fills in all of the T-SQL to help you create a table in the database.
Notice that all of the TableName placeholders are selected, ready for you to overwrite them with your own name. Type it once, and each one gets updated simultaneously. Press the tab key to move over to SchemaName and change that to "dbo" (since we haven't created any other schemas at this point). Then all that's left is to modify the Column1 and Column2 placeholders on lines 10 and 11, choose appropriate data types, and add additional columns as needed.
Press the Run button when done to create your first table, in your first database, on your SQL Server instance, running on Ubuntu Linux, inside of a Docker container, on your Mac.
Dig in deeper with my course SQL Server 2017: Linux, Docker, and MacOS
I go into way more detail on the process of working with SQL Server on these newly available platforms in my newest course here on LinkedIn Learning. In it, I demonstrate the process of setting up SQL Server on Linux, use the sqlcmd command line tool, dive deeper into Docker, and connect instances to and from other machines on the network. Or, for more information on how to use SQL Server now that you're up and running, check out Learn SQL Server 2017.
SQL Server 2017: Now on Linux, Docker, and macOS
SQL Server has traditionally run only on Windows. New for 2017 is the ability to install server instances and work with databases on Linux and in Docker containers, which opens the possibility of running SQL Server on macOS. With the extension tools now available as native Linux and macOS applications, users can capitalize on the variety of options available for running a database instance. This course shows how to install SQL Server on new platforms, and how to connect to it from a newly diverse array of environments. Instructor Adam Wilbert also shows how to use SQL Operations Studio to perform routine SQL Server maintenance tasks, such as backups, from Windows, macOS, and Linux.
- Installing, upgrading, and uninstalling SQL Server on Linux
- Connecting to SQL Server on Linux
- Issuing T-SQL commands Installing Docker on Windows and macOS
- Connecting to SQL Server from inside and outside a container
- Sharing data across containers
- Installing SQL tools on macOS
- Connecting to SQL Server on macOS Using SQL Operations Studio
- Backing up a database in Operations Studio
Duration: 1h 44m
Get Started Building Databases with SQL Server 2017
Microsoft SQL Server can be an intimidating system. In this course, instructor Adam Wilbert provides a quick overview of how SQL Server works—which can go a long way to making you feel more comfortable as you start exploring its powerful capabilities. Adam goes over the most important features of SQL Server 2017, helping to familiarize you with how the server operates. He introduces the main working environment—SQL Server Management Studio—and walks through how to start creating tables and manipulating data.
- Reviewing the different editions of SQL Server
- Configuring and starting the server
- Touring the SQL Server Management Studio (SSMS) interface
- Creating a new database on the server
- Creating a data table
- Joining tables together with keys
- Writing Transact-SQL commands
Duration: 1h 21m
Preview the newest features of SQL Server 2017
SQL Server 2017 is the start of the new annual release strategy by Microsoft. SQL developers no longer have to wait two or three years for enhancements. See what's new and notable in the 2017 release, in this overview with Adam Wilbert. See the new Linux compatibility in action, as Adam shows how to install SQL Server on Ubuntu, and learn how to use the machine learning services package, which includes R and Python scripting. Then find out how to use graph databases to model many-to-many relationships as nodes and edges. Adam also reviews the smaller enhancements like automatic query performance tuning and the new dynamic management views.
Duration: 1h 22m
Provision SQL Server instances on your local machines or in the cloud
Learn the key skills you need to provision SQL Server instances both on premises and using the cloud-based Azure service. In this course, Adam Wilbert reviews several ways of getting a SQL database up and running, helping you see the benefits and trade-offs of each option. He begins by explaining how to get started with Azure SQL Database, demonstrating how to deploy a database and choose the right service tier for you. He also shows how to deploy a virtual Windows Server machine, and migrate on-premises SQL Server databases to a SQL Server instance hosted on an Azure virtual machine.
This course is also ideal for anybody preparing for the Provisioning SQL Databases (70-765) exam, one of two exams necessary to earn an MCSA: SQL 2016 Database Administration certification.
Duration: 2h 44m
Your First Introduction to Relational Databases
Have you ever opened up a database that someone else built and felt a little lost? Or ever thought of designing your own simple database and been unsure of where to start? Or perhaps you need to work with a team of database professionals and don't know how to speak their language? This course can help you overcome these hurdles.
Adam Wilbert covers the basics of relational database design, regardless of whether you use Access, FileMaker, Open Office, or SQL Server. Learn how to prevent data anomalies, gather requirements to plan your design, and develop a conceptual data model—translating your ideas into components like tables, relationships, queries, and views. Plus, learn about logical design considerations that can help you construct a database that is easy to maintain.
- What is a database management system (DBMS)?
- Moving through the database development cycle
- Preventing duplicate, inconsistent, and conflicting data entries
- Gathering requirements
- Developing relationships
- Identifying key fields
- Following a naming convention
- Developing the actual database
Duration: 2h 43m