Linux系统安装sqlserver数据库

发布时间:2023年12月27日

前言:

众所周知,一开始sqlserver数据库是不支持liunx操作系统的,一直在Windows操作系统稳抓狠打。可能是某种原因,后面从sqlserver2017版本开始支持linux版本。如下进行一个测试安装。

环境介绍:

[root@exam01 soft]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@exam01 soft]# uname -a
Linux exam01 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@exam01 soft]#

sqlserver数据库版本:2019
mssql-server-15.0.4083.2-15.x86_64.rpm
参考:
https://packages.microsoft.com/rhel/7/mssql-server-2019/

安装部署

[root@exam01 soft]# rpm -ivh mssql-server-15.0.4083.2-15.x86_64.rpm
warning: mssql-server-15.0.4083.2-15.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mssql-server-15.0.4083.2-15      ################################# [100%]

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

根据提示执行如下脚本:

Please run 'sudo /opt/mssql/bin/mssql-conf setup'

[root@exam01 soft]# sudo /opt/mssql/bin/mssql-conf setup
usermod: no changes
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) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
  7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
  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=2109348&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):
....

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 Edition: Core-based Licensing].
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.

该步骤主要是选择版本和设置sa密码。

查看服务状态:

[root@exam01 soft]# systemctl status mssql-server --no-pager
● 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 Tue 2023-12-26 22:17:15 CST; 1min 23s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 19548 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─19548 /opt/mssql/bin/sqlservr
           └─19574 /opt/mssql/bin/sqlservr

Dec 26 22:17:27 exam01 sqlservr[19548]: 2023-12-26 22:17:27.27 spid11s     Clearing tempdb database.
Dec 26 22:17:27 exam01 sqlservr[19548]: 2023-12-26 22:17:27.77 spid11s     [2]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
Dec 26 22:17:27 exam01 sqlservr[19548]: 2023-12-26 22:17:27.77 spid11s     Starting up database 'tempdb'.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.33 spid11s     The tempdb database has 2 data file(s).
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.40 spid26s     The Service Broker endpoint is in disabled or stopped state.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.40 spid26s     The Database Mirroring endpoint is in disabled or stopped state.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.45 spid26s     Service Broker manager has started.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.46 spid8s      Recovery is complete. This is an informational message only. No user action is required.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.53 spid9s      Error: 46906, Severity: 16, State: 1.
Dec 26 22:17:28 exam01 sqlservr[19548]: 2023-12-26 22:17:28.53 spid9s      Unable to retrieve registry value 'NodeRole' from Windows registry key 'Software\Microsoft\Microsoft SQL Ser...ion': (null).
Hint: Some lines were ellipsized, use -l to show in full.
[root@exam01 soft]#

安装完成。客户端测试连接登录:

在这里插入图片描述
连接成功
在这里插入图片描述
登录成功
在这里插入图片描述

测试DDL&DML

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
至此测试成功。

文章来源:https://blog.csdn.net/bing_yuan/article/details/135232499
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。