Hello! I'm Justin with Liquid Web!
Microsoft SQL Server is a
relational database management
system created by Microsoft.
In this tutorial, we are
going to walk through how to
install MSSQL Server on CentOS 7
and Ubuntu 16.04.
Before we start, it's important
to be sure your server has at
minimum 2GB of memory.
Additionally, I'm logged into
each of these servers as the
root user and you should be as well.
We'll start with CentOS.
First, let's get our packages
updated, yum update -y.
Once that's finished, run this
curl command to add the mssql preview repo:
curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo
Now that yum knows where to
look for it install the
mssql-server package,
yum install -y mssql-server.
Next, we need to run the
configuration script, enter the command
/opt/mssql/bin/mssql-conf setup.
MSSQL Server is not open-source
unlike MySQL and PostgreSQL.
In light of this fact, we have to
choose an edition. I'll be
choosing Developer or choice 2,
because it's free.
The next prompt is to accept
the license terms, enter Yes
and hit enter.
Now we are being prompted to
create a password for the SQL
Server system administrator.
Enter the password of your
choosing, hit enter, then do the
same again to confirm it.
The mssql-server service should
be running now. To confirm this
run the command
systemctl status mssql-server.
Now that MSSQL Server is
running, we need a way to
interact with it.
Start by adding the Microsoft
Red Hat repository: curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
Next install the command-line
tools with this command
yum install -y mssql-tools unixODBC-devel
You'll be prompted a couple of
times to accept the license terms.
In order to make it easier to
ensure we can execute SQL
commands from anywhere on the
server, run these commands - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc && source ~/.bashrc
verify we can connect to the SQL Server locally run,
sqlcmd -S localhost -U SA,
enter the password you setup
during the configuration step.
You should notice your command
prompt changes to the number 1
followed by an angle bracket.
That's it!
You now have a functioning
MSSQL Server install on your
CentOS 7 server.
Next up, Ubuntu 16.04.
First, let's update packages,
apt-get update -y.
After that, we need to add the
GPG keys for the MSSQL Server Ubuntu 2019 preview repo.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
Now that the GPG keys are in
place we need to actually add the repo.
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
The package repo we just added,
requires an https connection.
In order to make sure it's
possible for apt to connect over
https, run this command,
apt-get install -y apt-transport-https
Now we need to update apt so it
is aware of the repo we just
added by running
apt-get update -y.
Now let's install mssql-server,
apt-get install -y mssql-server
Time for configuration!
This step will be almost
identical to the process
for CentOS 7.
Run the command
/opt/mssql/bin/mssql-conf setup
I'm going to enter 2 for the
edition, Yes to accept the
license terms, and the SQL
Server Admin password.
Now that it's configured,
let's verify it's running by
running this command
systemctl status mssql-server --no-pager
Just like with CentOS 7 we now
need a way to interact with
MSSQL Server.
First, we need to add the GPG
keys for the repo that contains
the mssql-tools package by running this command.
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
After that, we can add the repo with the following curl command curl
https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/msprod.list
Now that the repo is added,
update apt with
apt-get update -y and install
the command-line tools with
apt-get install -y mssql-tools unixodbc-dev
You'll notice some interactive
prompts to accept the licenses
for these packages, accept them
and move on.
After that, we will add
mssql-tools to the PATH
variable so we can execute
sql commands anywhere on the machine
by running these commands.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc && source ~/.bashrc
Now it's time to verify that we
can connect to MSSQL Server
locally by running this command
sqlcmd -S localhost -U SA.
Now enter the password you
configured earlier and again,
you should see the prompt
change to the number 1
followed by an angle bracket.
There you have it! You've now
successfully installed MSSQL
Server on both CentOS 7 and
Ubuntu 16.04.
Thanks for watching! For more
information, visit our Knowledge
Base at liquidweb.com/kb or, our
YouTube channel at
youtube.com/user/liquidwebinc!