SQL SEVER ON LINUX

Admin@123


Follow the  installation guide from Microsoft:

Downloading Repo

[root@dfwlncmssql-01 ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://pack                                                                                                                     ages.microsoft.com/config/rhel/7/mssql-server-2017.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:02:07 --:--:--     0curl: (7) Failed connect to packages.microsoft.com:443; Connection timed out


[root@dfwlncmssql-01 ~]#
[root@dfwlncmssql-01 ~]#
[root@dfwlncmssql-01 ~]#
[root@dfwlncmssql-01 ~]# ls -lrt /etc/yum.repos.d/
total 16
-rw-r--r--. 1 root root 1550 Sep  8  2016 puppetlabs.repo
-rw-r--r--  1 root root 6282 Jun 13 19:57 public-yum-ol7.repo-disabled
-rw-r--r--  1 root root  232 Jun 15 15:27 mssql-server-2017.repo

[root@dfwlncmssql-01 ~]# cd /etc/yum.repos.d/
[root@dfwlncmssql-01 yum.repos.d]# ls
mssql-server-2017.repo  public-yum-ol7.repo-disabled  puppetlabs.repo

Installing SQL SERVER

[root@dfwlncmssql-01 yum.repos.d]# sudo yum install -y mssql-server
Loaded plugins: langpacks, rhnplugin, ulninfo
This system is receiving updates from ULN.
packages-microsoft-com-mssql-server-2017                                                                                                                                      | 2.9 kB  00:00:00
puppetlabs-deps                                                                                                                                                               | 2.5 kB  00:00:00
puppetlabs-products                                                                                                                                                           | 2.5 kB  00:00:00
packages-microsoft-com-mssql-server-2017/primary_db                                                                                                                           |  12 kB  00:00:05
oracle_linux_7_addons-x86_64                                                                                                                                                  | 1.0 kB  00:00:00
oraclelinux7-x86_64-optional                                                                                                                                                  | 1.0 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.3026.27-2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================================
 Package                                  Arch                               Version                                      Repository                                                            Size
=====================================================================================================================================================================================================
Installing:
 mssql-server                             x86_64                             14.0.3026.27-2                               packages-microsoft-com-mssql-server-2017                             168 M

Transaction Summary
=====================================================================================================================================================================================================
Install  1 Package

Total download size: 168 M
Installed size: 168 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/packages-microsoft-com-mssql-server-2017/packages/mssql-server-14.0.3026.27-2.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY 00:00:00 ETA
Public key for mssql-server-14.0.3026.27-2.x86_64.rpm is not installed
mssql-server-14.0.3026.27-2.x86_64.rpm                                                                                                                                        | 168 MB  00:00:03
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
 From       : https://packages.microsoft.com/keys/microsoft.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-14.0.3026.27-2.x86_64                                                                                                                                                1/1

+--------------------------------------------------------------+
Please run 'sudo /opt/mssql/bin/mssql-conf setup'
to complete the setup of Microsoft SQL Server
+--------------------------------------------------------------+

SQL Server needs to be restarted in order to apply this setting. Please run
'systemctl restart mssql-server.service'.
  Verifying  : mssql-server-14.0.3026.27-2.x86_64                                                                                                                                                1/1

Installed:
  mssql-server.x86_64 0:14.0.3026.27-2

Complete!


Configuring Setup

[root@dfwlncmssql-01 yum.repos.d]# sudo /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID)
  7) Enterprise Core (PAID)
  8) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-8): 1
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855864&clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409

Do you accept the license terms? [Yes/No]:Yes

Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Enterprise Evaluation Edition].
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.


Check the status of SQL Server

[root@dfwlncmssql-01 yum.repos.d]# systemctl status mssql-server
â mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-06-15 15:33:29 CDT; 24s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 19888 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ââ19888 /opt/mssql/bin/sqlservr
           ââ19910 /opt/mssql/bin/sqlservr

Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.11 spid5s      8 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No u...is required.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.14 spid5s      0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user...is required.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.16 spid9s      Polybase feature disabled.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.17 spid9s      Clearing tempdb database.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.57 spid9s      Starting up database 'tempdb'.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.82 spid9s      The tempdb database has 1 data file(s).
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.83 spid20s     The Service Broker endpoint is in disabled or stopped state.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.83 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.86 spid20s     Service Broker manager has started.
Jun 15 15:33:34 dfwlncmssql-01 sqlservr[19888]: 2018-06-15 15:33:34.89 spid5s      Recovery is complete. This is an informational message only. No user action is required.
Hint: Some lines were ellipsized, use -l to show in full.

Enable Port 1433


[root@dfwlncmssql-01 yum.repos.d]# firewall-cmd --zone=public --add-port=1433/tcp --permanent
FirewallD is not running


Setting PATH


[root@dfwlncmssql-01 yum.repos.d]# echo $PATH


[root@dfwlncmssql-01 yum.repos.d]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@dfwlncmssql-01 yum.repos.d]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@dfwlncmssql-01 yum.repos.d]# source ~/.bashrc

[root@dfwlncmssql-01 yum.repos.d]# echo $PATH


/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/mssql-tools/bin


[root@dfwlncmssql-01 yum.repos.d]# sqlcmd -S localhost -U SA
-bash: sqlcmd: command not found

 Installing Tools

downloaded the prod.repo file and scp it to the host (https://packages.microsoft.com/config/rhel/7/prod.repo)

[root@dfwlncmssql-01 yum.repos.d]# cp /tmp/prod.repo /etc/yum.repos.d/msprod.repo
cp: overwrite â/etc/yum.repos.d/msprod.repoâ? yes
[root@dfwlncmssql-01 yum.repos.d]# yum install mssql-tools
Loaded plugins: langpacks, rhnplugin, ulninfo
This system is receiving updates from ULN.
packages-microsoft-com-prod                                                                                                                                                   | 2.9 kB  00:00:00
packages-microsoft-com-prod/primary_db                                                                                                                                        | 116 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:17.1.0.1-1 will be installed
--> Processing Dependency: msodbcsql17 < 17.2.0.0 for package: mssql-tools-17.1.0.1-1.x86_64
--> Processing Dependency: msodbcsql17 >= 17.1.0.1 for package: mssql-tools-17.1.0.1-1.x86_64
--> Running transaction check
---> Package msodbcsql17.x86_64 0:17.1.0.1-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================================
 Package                                      Arch                                    Version                                     Repository                                                    Size
=====================================================================================================================================================================================================
Installing:
 mssql-tools                                  x86_64                                  17.1.0.1-1                                  packages-microsoft-com-prod                                  253 k
Installing for dependencies:
 msodbcsql17                                  x86_64                                  17.1.0.1-1                                  packages-microsoft-com-prod                                  4.1 M

Transaction Summary
=====================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 4.4 M
Installed size: 4.4 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): mssql-tools-17.1.0.1-1.x86_64.rpm                                                                                                                                      | 253 kB  00:00:00
(2/2): msodbcsql17-17.1.0.1-1.x86_64.rpm                                                                                                                                      | 4.1 MB  00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                9.2 MB/s | 4.4 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
The license terms for this product can be downloaded from
https://aka.ms/odbc170eula and found in
/usr/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
yes
  Installing : msodbcsql17-17.1.0.1-1.x86_64                                                                                                                                                     1/2
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
yes
  Installing : mssql-tools-17.1.0.1-1.x86_64                                                                                                                                                     2/2
  Verifying  : msodbcsql17-17.1.0.1-1.x86_64                                                                                                                                                     1/2
  Verifying  : mssql-tools-17.1.0.1-1.x86_64                                                                                                                                                     2/2

Installed:
  mssql-tools.x86_64 0:17.1.0.1-1

Dependency Installed:
  msodbcsql17.x86_64 0:17.1.0.1-1

Complete!


Connect to SQL

[root@dfwlncmssql-01 yum.repos.d]# sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 17.1.0000.1 Linux
Copyright (c) 2012 Microsoft. All rights reserved.

usage: sqlcmd            [-U login id]          [-P password]
  [-S server or Dsn if -D is provided]
  [-H hostname]          [-E trusted connection]
  [-N Encrypt Connection][-C Trust Server Certificate]
  [-d use database name] [-l login timeout]     [-t query timeout]
  [-h headers]           [-s colseparator]      [-w screen width]
  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
  [-c cmdend]
  [-q "cmdline query"]   [-Q "cmdline query" and exit]
  [-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]
  [-u unicode output]    [-r[0|1] msgs to stderr]
  [-i inputfile]         [-o outputfile]
  [-k[1|2] remove[replace] control characters]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-p[1] print statistics[colon format]]
  [-R use client regional setting]
  [-K application intent]
  [-M multisubnet failover]
  [-b On error batch abort]
  [-D Dsn flag, indicate -S is Dsn]
  [-X[1] disable commands, startup script, environment variables [and exit]]
  [-x disable variable substitution]
  [-? show syntax summary]
 
[root@dfwlncmssql-01 yum.repos.d]# sqlcmd -S localhost -U SA
Password:

1> select name from sys.databases;
2> go
name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb

(4 rows affected)
1> create database kishore
2> go
1> use kishore
2> go
Changed database context to 'kishore'.
1> select name from sys.tables;
2> go
name
--------------------------------------------------------------------------------------------------------------------------------

(0 rows affected)
1> create table kishore (id int, name char(20))
2> go
1> insert into kishore (1, 'dex')
2> go
Msg 102, Level 15, State 1, Server dfwlncmssql-01, Line 1
Incorrect syntax near ')'.
1> insert into kishore values (1, 'dex'); go;
2> go
Msg 102, Level 15, State 1, Server dfwlncmssql-01, Line 1
Incorrect syntax near 'go'.
1> insert into kishore values (1, 'dex')
2> go

(1 rows affected)
1> select * from kishore
2> go
id          name
----------- --------------------
          1 dex

(1 rows affected)
1>

Comments

Popular posts from this blog

Netezza Commands

MS SQL Server Tips