CentOS 安装 SQL Server
Last login: Sat Jul 27 15:50:06 2019
[root@localhost ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-preview.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 240 100 240 0 0 135 0 001 0
01 —:—:— 135
[root@localhost ~]# yum install -y mssql-server
BDB2053 Freeing read locks for locker 0x26e: 21122/140371365746496
BDB2053 Freeing read locks for locker 0x270: 21122/140371365746496
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* extras: mirror.lzu.edu.cn
* updates: mirror.lzu.edu.cn
packages-microsoft-com-mssql-server-preview | 2.9 kB 00:00
packages-microsoft-com-mssql-server-preview/primary_db | 104 kB 00:03
Resolving Dependencies
--> Running transaction check
-—> Package mssql-server.x86_64 0:15.0.1800.32-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package
Arch Version Repository Size
Installing:
mssql-server
x86_64 15.0.1800.32-1 packages-microsoft-com-mssql-server-preview 208 M
Transaction Summary
Install 1 Package
Total download size: 208 M
Installed size: 208 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-mssql-server-preview/packages/mssql-server-15.0.1800.32-1.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-15.0.1800.32-1.x86_64.rpm is not installed
mssql-server-15.0.1800.32-1.x86_64.rpm | 208 MB 30:50
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-15.0.1800.32-1.x86_64 1/1
+———————————————————————————————+
Please run ‘sudo /opt/mssql/bin/mssql-conf setup’
to complete the setup of Microsoft SQL Server
+———————————————————————————————+
Verifying : mssql-server-15.0.1800.32-1.x86_64 1/1
Installed:
mssql-server.x86_64 0:15.0.1800.32-1
Complete!
[root@localhost ~]# /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=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:
The specified password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: uppercase letters, lowercase letters, numbers, and symbols.
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server…
This is an evaluation version. There are [175] days left in the evaluation period.
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.
[root@localhost bin]# 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 Sat 2019-07-27 16:29:53 CST; 1min 28s ago
Docs: https://docs.microsoft.com/en-us/sql/linux
Main PID: 22328 (sqlservr)
CGroup: /system.slice/mssql-server.service
tq22328 /opt/mssql/bin/sqlservr
mq22354 /opt/mssql/bin/sqlservr
Jul 27 16:30:01 localhost sqlservr[22328]: 2019-07-27 16:30:01.60 Server …
Jul 27 16:30:01 localhost sqlservr[22328]: 2019-07-27 16:30:01.74 Server ….
Jul 27 16:30:01 localhost sqlservr[22328]: 2019-07-27 16:30:01.74 Server ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.11 spid14s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.12 spid14s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.76 spid14s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.77 spid25s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.77 spid25s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.79 spid25s ….
Jul 27 16:30:02 localhost sqlservr[22328]: 2019-07-27 16:30:02.80 spid7s ….
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost bin]# firewall-cmd —zone=public —add-port=1433/tcp —permanent
success
[root@localhost bin]# firewall-cmd —reload
success
[root@localhost bin]# curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 118 0 001 0
01 —:—:— 118
[root@localhost bin]# yum install -y mssql-tools unixODBC-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirror.lzu.edu.cn
* updates: mirror.lzu.edu.cn
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
packages-microsoft-com-mssql-server-preview | 2.9 kB 00:00
packages-microsoft-com-prod | 2.9 kB 00:00
Not using downloaded packages-microsoft-com-prod/repomd.xml because it is older than what we have:
Current : Sat Jul 27 06:03:01 2019
Downloaded: Thu Jul 25 09:11:58 2019
updates | 3.4 kB 00:00
packages-microsoft-com-prod/pr FAILED
https://packages.microsoft.com/rhel/7/prod/repodata/86dadde547a7137fe4f6d657a4d4e5132248f8027e3aeed762dd205ef48f78b9-primary.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn’t help to resolve this issue please use https://bugs.centos.org/.
packages-microsoft-com-prod/primary_db | 198 kB 00:01
Resolving Dependencies
--> Running transaction check
-—> Package mssql-tools.x86_64 0:17.3.0.1-1 will be installed
--> Processing Dependency: msodbcsql17 < 17.4.0.0 for package: mssql-tools-17.3.0.1-1.x86_64
--> Processing Dependency: msodbcsql17 >= 17.3.0.0 for package: mssql-tools-17.3.0.1-1.x86_64
-—> Package unixODBC-devel.x86_64 0:2.3.7-1.rh will be installed
--> Processing Dependency: unixODBC = 2.3.7 for package: unixODBC-devel-2.3.7-1.rh.x86_64
--> Running transaction check
-—> Package msodbcsql17.x86_64 0:17.3.1.1-1 will be installed
-—> Package unixODBC.x86_64 0:2.3.7-1.rh will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
Installing:
mssql-tools x86_64 17.3.0.1-1 packages-microsoft-com-prod 254 k
unixODBC-devel x86_64 2.3.7-1.rh packages-microsoft-com-prod 42 k
Installing for dependencies:
msodbcsql17 x86_64 17.3.1.1-1 packages-microsoft-com-prod 769 k
unixODBC x86_64 2.3.7-1.rh packages-microsoft-com-prod 213 k
Transaction Summary
Install 2 Packages (+2 Dependent packages)
Total download size: 1.2 M
Installed size: 1.2 M
Downloading packages:
(1/4): mssql-tools-17.3.0.1-1.x86_64.rpm | 254 kB 00:05
(2/4): unixODBC-2.3.7-1.rh.x86_64.rpm | 213 kB 00:04
(3/4): unixODBC-devel-2.3.7-1.rh.x86_64.rpm | 42 kB 00:01
(4/4): msodbcsql17-17.3.1.1-1.x86_64.rpm | 769 kB 00:10
-———————————————————————————————————————-
Total 117 kB/s | 1.2 MB 00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : unixODBC-2.3.7-1.rh.x86_64 1/4
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula 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.3.1.1-1.x86_64 2/4
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.3.0.1-1.x86_64 3/4
Installing : unixODBC-devel-2.3.7-1.rh.x86_64 4/4
Verifying : unixODBC-devel-2.3.7-1.rh.x86_64 1/4
Verifying : unixODBC-2.3.7-1.rh.x86_64 2/4
Verifying : mssql-tools-17.3.0.1-1.x86_64 3/4
Verifying : msodbcsql17-17.3.1.1-1.x86_64 4/4
Installed:
mssql-tools.x86_64 0:17.3.0.1-1 unixODBC-devel.x86_64 0:2.3.7-1.rh
Dependency Installed:
msodbcsql17.x86_64 0:17.3.1.1-1 unixODBC.x86_64 0:2.3.7-1.rh
Complete!
[root@localhost bin]# echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile
echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
[root@localhost bin]# echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
[root@localhost bin]# source ~/.bashrc
[root@localhost bin]# sqlcmd -S localhost -U SA -P password
1>
1> CREATE DATABASE TestDB
2> go
1> SELECT Name from sys.Databases
2> go
Name
-———————————————————————————————————————————————————————————————-
master
tempdb
model
msdb
TestDB
(5 rows affected)
1> USE TestDB
2> go
Changed database context to ‘TestDB’.
1> CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
2> go
1> INSERT INTO Inventory VALUES (1, ‘banana’, 150); INSERT INTO Inventory VALUES (2, ‘orange’, 154);
2> go
(1 rows affected)
(1 rows affected)
1> go
1> SELECT * FROM Inventory WHERE quantity > 152;
2> go
id name quantity
-————— ————————————————————————— —————-
2 orange 154
(1 rows affected)
1> quit
[root@localhost bin]#
SELECT @@version |
-———————————————————————————————————————————————————————————————————————————————————————————————————-|
Microsoft SQL Server 2019 (CTP3.2) - 15.0.1800.32 (X64) ¶ Jul 17 2019 21:29:33 ¶ Copyright (C) 2019 Microsoft Corporation¶ Enterprise Evaluation Edition (64-bit) on Linux (CentOS Linux 7 (Core))
SELECT * FROM sys.sysdatabases
name |dbid|sid|mode|status|status2 |crdate |reserved |category|cmptlevel|filename |version|
-——-|——|—-|——|———|—————|—————————-|—————————-|————|————-|————————————————|———-|
master| 1| | 0| 65544|1090520064|2003-04-08 09:13:36|1900-01-01 00:00:00| 0| 150|/var/opt/mssql/data/master.mdf | 904|
tempdb| 2| | 0| 65544|1090520064|2019-07-27 16:30:02|1900-01-01 00:00:00| 0| 150|/var/opt/mssql/data/tempdb.mdf | 904|
model | 3| | 0| 65536|1090519040|2003-04-08 09:13:36|1900-01-01 00:00:00| 0| 150|/var/opt/mssql/data/model.mdf | 904|
msdb | 4| | 0| 65544|1627390976|2019-07-17 22:15:18|1900-01-01 00:00:00| 0| 150|/var/opt/mssql/data/MSDBData.mdf| 904|
TestDB| 5| | 0| 65536|1627389952|2019-07-27 16:34:42|1900-01-01 00:00:00| 0| 150|/var/opt/mssql/data/TestDB.mdf | 904|
还没有评论,来说两句吧...