Geeks With Blogs
Jeremy Morgan Ramblings of a Polyglot coder
I must admit I was surprised when I learned that Microsoft SQL Server would be available in Linux. They've been pushing the open source initiative hard, but I didn't expect something this big. Oh yeah, Visual Studio is now available for Mac as well. I just saw a pig flying by. 
While MS-SQL is not open source they have made it available to run on open source platforms such as Linux and OSX, which I can imagine took a ton of work. So I decided to take advantage of this new option and try it out. It works great! It took 5 minutes to install. Here's how you can do it too. Note that you will need a server with 3.5 gigs of RAM for this. 

The first thing I always do on an Ubuntu machine is update it


sudo apt-get update
sudo apt-get upgrade


Next we need to import the public repository GPG keys


curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list


Next we'll install SQL Server. 

sudo apt-get update
sudo apt-get install -y mssql-server


Now we need to run a configuration script to set up the server:

sudo /opt/mssql/bin/sqlservr-setup

It will ask if you want to start the service and if you'd like to start it on boot. 

Here's how you can check if the service is running:

systemctl status mssql-server


Install the MSSQL Tools for Linux

To test this out a little, install the MSSQL tools on Ubuntu. 

Add in a new repository:

curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

sudo apt-get update 
sudo apt-get install mssql-tools

Now, Let's try to connect! 

sqlcmd -S localhost -U SA -P '<YourPassword>'

You can run this command to view all your databases:

SELECT Name from sys.Databases;
GO


This should look pretty familiar to you if you've worked with SQL in the past. 

CREATE DATABASE acmewidgets;
GO

Now we need to select that database:

USE acmewidgets;
GO

As a test. let's create a customer table

CREATE TABLE customer (id INT, firstname NVARCHAR(50), lastname NVARCHAR(50));
GO

Now, let's put some customers in there:

INSERT INTO customer VALUES (1, 'Lloyd', 'Christmas');
INSERT INTO customer VALUES (2, 'Harry', 'Dunn');
INSERT INTO customer VALUES (3, 'Mary', 'Swanson');
GO

Now, let's take a look at those customers:

SELECT * FROM customer
GO


And it's that easy! You can run SQL scripts here, or connect to it from SSMS, a traditional ASP site, or a .Net Core site/app. I'll be doing a lot of ASP.Net core work in the coming months, so be sure to check back here.

To quit from SQL server, type in 

QUIT

And you're done!

I'll be messing with this some more in the coming weeks and really putting it to the test, and I'll share my results. 

-Jeremy

I also did a YouTube tutorial for this article:


Thanks!



Are you an IIS Administrator? Do you want to be one? Check out my new  IIS Administration Fundamentals course at Pluralsight!

- Jeremy


Posted on Thursday, December 8, 2016 4:11 PM Tutorials , asp.net , asp.net core , SQL Server | Back to top


Comments on this post: How to Install Microsoft SQL Server on Ubuntu Linux

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
This information is very helpful and useful. In this post good explanation about how to install sql in Ubuntu. in this post step by step explanation that helps people.

http://www.thecheesyanimation.com/Interior-Design-&-Rendering.html
Left by Bhavik Solanki on Dec 08, 2016 9:50 PM

# company formation uk
Requesting Gravatar...
Hi
Excellent article.its very intresting andvery helpful for seo workers.
Thank you for sharing
Have a niceday
thank you
https://www.globalcompanyformation.co.uk/Index.html
Left by vikas pv pv on Dec 08, 2016 10:29 PM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
I have faced some challenges installing MySql, even installing a Wamp server on a VM running Ubuntu has been a trouble for me

http://cbps.uonbi.ac.ke/
Left by Munyole on Dec 10, 2016 1:07 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
I don't understand why we need to run these two commands everytime. Question is stupid, I know. :P
sudo apt-get update
sudo apt-get upgrade
Left by Shivani Sharma on Dec 10, 2016 8:41 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
The reason that's run twice is because you're adding in new repositories. You can add all the repositories at once and run it once if you'd like.
Left by Jeremy on Dec 10, 2016 11:11 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
Certschief group is putting forth affirmation exams inquiries and answers for Microsoft, CompTia, IBM, HP and much more downloadable practice exam for IT experts.
http://www.certschief.com/
Left by James Stiles on Dec 11, 2016 9:40 PM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
Certschief group is putting forth affirmation exams inquiries and answers for Microsoft, CompTia, IBM, HP and much more downloadable practice exam for IT experts.
http://www.certschief.com/
Left by James Stiles on Dec 11, 2016 9:41 PM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
de duoc huong dan su dung cung nhu biet them ve cac tinh nang cua thuoc cuong duong tai nha thuoc dong y huynh tan trieu cac ban vui long doc lien he trong link nhe
Left by alex on Dec 12, 2016 2:01 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
=https://www.google.com.pk/>didn't get it
Left by Georgina Douglas on Dec 13, 2016 11:03 PM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
Microsoft is good software company but now a days google android is going to bost software market where we can change life Custom Assignment Help Service
Left by Adam Micheal on Dec 20, 2016 5:24 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
You can add all the repositories at once and run it once if you'd like. NFL Snapback Hats
Left by Mallo on Dec 23, 2016 2:21 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
Left by wagnore on Jan 11, 2017 12:37 PM

# nice video
Requesting Gravatar...
nice
facevook
Left by marlis on Jan 29, 2017 4:31 AM

# showmeashop
Requesting Gravatar...
Thanks for providing great infomation. i have bookmarked your post.For more info: GearBest Discounts
Left by mickle joan on Jan 29, 2017 4:34 AM

# Advanced SystemCare
Requesting Gravatar...
This is such a nice great website with lots of good information, thanks! Advanced SystemCare License Key
Left by Malakai39 on Jan 30, 2017 10:51 PM

# transcription services
Requesting Gravatar...
Thank you for the great article I did enjoyed reading it, I will be sure to bookmark your blog and definitely will come back from again.
transcribe spanish to english
Left by Colby Cote on Jan 31, 2017 8:58 PM

# universal keygen generator
Requesting Gravatar...
It is truly a great and helpful piece of info,Excellent blog,Thanks for sharing.
universal keygen generator
Left by Jeremiah6 on Feb 01, 2017 4:00 AM

# botox cosmetic san fernando valley
Requesting Gravatar...
Thanks for share this blog with us.Really we appreciate after reading this post.
botox cosmetic san fernando valley
Left by jamio65 on Feb 01, 2017 6:41 AM

# Ashampoo Driver Updater
Requesting Gravatar...
Thanks for share this blog with us.Really we appreciate after reading this post.
Ashampoo Driver Updater
Left by Harold11 on Feb 02, 2017 4:00 AM

# re: How to Install Microsoft SQL Server on Ubuntu Linux
Requesting Gravatar...
de duoc huong dan su dung cung nhu biet them ve cac tinh nang cua thuoc cuong duong duoc rat nhieu nam gioi tin dung tai viet nam cac ban co the tham khao link tren nhe.
Left by ThanhTrung on Feb 08, 2017 1:18 AM

# How to get Discounts
Requesting Gravatar...
Save On Web hosting and Domains with our Latest GoDaddy Promo Codes & Promo Codes. GoDaddy is one of the world's largest domain name registrars.
Left by 365dayscoupons on Feb 09, 2017 1:51 AM

# fast car
Requesting Gravatar...
Your article perceftly shows what I needed to know, thanks!
2017 Audi Q1
Left by Gavin82 on Feb 10, 2017 3:37 AM

# epaulettes
Requesting Gravatar...
Thanks for providing great infomation. i have bookmarked your post.
sword knot
Left by Isaiah50 on Feb 13, 2017 12:06 AM

# Makeup case
Requesting Gravatar...
Thanks a lot for sharing this informative blog. Thank you Hair Salon Supplies
Left by Isaiah50 on Feb 13, 2017 10:06 PM

# auto
Requesting Gravatar...
This is really an informative and awesome blog to see, thanks for sharing such a terrific blog..
Grand tourer | 2017 lexus rc
Left by Josiah28 on Feb 16, 2017 8:20 PM

Your comment:
 (will show your gravatar)


Copyright © Jeremy Morgan | Powered by: GeeksWithBlogs.net