MS SQL Server
Overview
Microsoft SQL server is a database management system, with the primary function of storing and retrieving data as requested by other software applications.
Installing MS SQL
Windows
Go to the following website: https://www.microsoft.com/en-us/sql-server/sql-server-downloads?rtc=1
Locate which edition you would like to download and click
Download Now.
In this example, downloadSQL Server 2019 Developer, a free full-featured edition to use as a development and test database in a non-production environment.If you encounter the following error when downloading,
A required file could not be downloaded. This could mean the version of the installer is no longer supported, please do the following:Open Powershell as administrator
Run:
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type Dword Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DwordRetry to download and run the installer
Double-click and open the downloaded installation file.
Choose an installation type, specify the folder and click
Install.Note: Choosing
Customallows for more customization for instance and user configuration.If you selected
Custom, the following window appears after the installation completes. In the left-menu clickInstallation. Then clickNew SQL Server stand-alone installation or add features to an existing installation.Again, specify which SQL edition you wish to install.
Click
Nextto continue. You’ll pass a page namedInstall Rulesand it will test and execute rules.In the
Feature Selectionwindow, selectDatabase Engine ServicesandSQL Client Connectivity SDK. Then clickNext.Specify the name and instance ID for the SQL server and click
Next.Change to default service configuration so that
SQL Server AgentandSQL Server Browserhave startup type set toAutomatic. ClickNext.In the
Database Engine Configuration, choose theMixed Modeauthentication. Enter the password for the administrator (sa) account and clickAdd current userto add the host machine as an admin.After clicking
Next, clickInstallto start the installation process. Once complete, you should see something similar to the following:
You have now installed MS SQL Server.
See the following section below to install SSMS to interact with the server: <once published, insert link to SSMS section below>
Linux
MS SQL servers only supports the following platforms: RHEL, SLES, Ubuntu, and Docker.
Ubuntu 16.04 or 18.04
Import the public repository GPG keys.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -Install SQL Server 2017 or 2019.
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"If using Ubuntu 16.04, in line 2 replace
.../ubuntu/18.04/...with.../ubuntu/16.04/....Update or install SQL Server.
sudo apt-get update sudo apt-get install -y mssql-serverRun the following to choose which edition to install.
sudo /opt/mssql/bin/mssql-conf setupYou’ll be prompted choose which edition by typing the corresponding value from
[1-8].
Then, you’ll also be asked to input a password for theSQL Server system administrator.To check the server is active, run the following command:
sudo systemctl status mssql-server.serviceInstall SQL Server command-line tools.
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - sudo curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list sudo curl -o /etc/apt/sources.list.d/mssql-server.list https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list sudo apt-get update sudo apt-get install mssql-tools unixodbc-devIf using Ubuntu 16.04, in line 2 replace
.../ubuntu/18.04/...with.../ubuntu/16.04/....Verify installation of
mssql-toolsand enable to your user profile.sudo ls /opt/mssql-tools/bin/sqlcmd* sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmdConnect by running the following command, where
servernameis the SQL server name (orlocalhostfor host connection) andsais the username.
Notes:sais the default admin username. For the default instance, the server name is the computer name or IP address.sqlcmd -S servername -U sa
Install MS SQL Service Management Studio
To interact with SQL servers, install SQL Server Management Studio (SSMS). It is a software for querying, designing and managing the server on your local computer or cloud.
SSMS supports Windows operating systems.
Under the section Download SSMS, click
Download SQL Server Management Studio.Once the installation file is done downloading. double-click and open it.
Click
Installin the Installer.Once it’s done, click
Close.In the Windows search bar, type
ssmsand clickOpen.In SSMS, type the
servernameof the SQL server, select theauthenticationmethod, and type the username and password.
In the example below, the server name islocalhost(since the machine is the host) and authentication method isWindows, so no further input was needed.Click
Connect.
AutoStart SQL Server Agent on System Startup
Windows
On the host computer, in the Windows search bar, type
sql server 2019 configuration managerand double-click to open.Click on
SQL Server Services.Right-click on
SQL Server Agentand clickProperties.In the
Propertieswindow, click theServiceTab and changeStart ModetoAutomaticthen clickOk.
Linux (Ubuntu 16.04 or 18.04)
On the host computer, run the following command to check status and enable
autostart:
sudo systemctl status mssql-server.service
sudo systemctl enable mssql-server.serviceAllow Remote Connections (Windows)
Enable protocols.
In the Windows search bar, type
sql server 2019 configuration managerand double-click to open.In SQL Server Configuration Manager, expand
SQL Server Network Configuration, and then clickProtocols for Instance Name.The default instance (an unnamed instance) is listed as
MSSQLSERVER. If you installed a named instance, the name you provided is listed.
Right-click
TCP/IP, and then clickEnable.
Configure a fixed port.
In SQL Server Configuration Manager, expand
SQL Server Network Configuration, and then clickProtocols for Instance Name.Double-click
TCP/IP.In the
TCP/IP Propertiesdialog box, click theIP Addressestab.In the
TCP Portbox of theIPAllsection, type1433for a default instance or49172for a named instance.Click
OKto close the dialog box, and clickOKto the warning that the service must be restarted.In the left pane, click
SQL Server Services.Right-click
SQL Server (Instance name), and then clickRestart.
Open ports in the firewall.
In the Windows Start menu, search and click
Run, typeWF.msc, and then clickOK.In Windows Firewall with Advanced Security, in the left pane, right-click
Inbound Rules, and then clickNew Rulein the action pane.In the
Rule Typedialog box, selectPort, and then clickNext.In the
Protocol and Portsdialog box, selectTCP. SelectSpecific local ports, and then type the port number of the instance of the Database Engine. Type1433for the default instance. Type49172if you are configuring a named instance. ClickNext.In the
Actiondialog box, selectAllow the connection, and then clickNext.In the
Profiledialog box, select any profiles that describe the computer connection environment when you want to connect to the Database Engine, and then clickNext.In the
Namedialog box, type a name and description for this rule, and then clickFinish.
Connecting from another computer.
On a second computer that contains the SQL Server client tools, log in with an account authorized to connect to SQL Server, and open Management Studio.
In the
Connect to Serverdialog box, confirmDatabase Enginein theServer typebox.In the
Server namebox, typetcp:<computer name>,<port number>.
To connect to the default instance, the port 1433 is implied; therefore, typetcp:<computer_name>.
For a named instance, typetcp:<computer_name>,49172.Note: If you omit
tcp:from the Server name box, then the client will attempt all protocols that are enabled, in the order specified in the client configuration.Select the
authenticationmethod and inputuser nameandpasswordif prompted. Then clickConnect.