SQL Server on Linux 也发布一段时间了,官方上支持 Red Hat , SUSE , Ubuntu 。手上没有以上 Linux 版本,选用了与 Red Hat 最接近的 CentOS 7.4 来进行安装和测试。
Linux: CentOS Linux release 7.4.1708 (Core)
Memory: 4 GB
SQL Server: SQL Server 2017 (RC2) - 14.0.900.75 (X64)
[root@linuxidc /opt]# mkdir -p /opt/sqlserver2017[root@linuxidc /opt]# cd /opt/sqlserver2017/[root@linuxidc /opt]#wget https://packages.microsoft.com/rhel/7/mssql-server/mssql-server-14.0.900.75-1.x86_64.rpm
[root@linuxidc /opt/sqlserver2017]# yum localinstall mssql-server-14.0.900.75-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacksRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationExamining mssql-server-14.0.900.75-1.x86_64.rpm: mssql-server-14.0.900.75-1.x86_64Marking mssql-server-14.0.900.75-1.x86_64.rpm to be installedResolving Dependencies--> Running transaction check---> Package mssql-server.x86_64 0:14.0.900.75-1 will be installed--> Finished Dependency ResolutionDependencies Resolved=========================================================================================================================================================================== Package Arch Version Repository Size===========================================================================================================================================================================Installing: mssql-server x86_64 14.0.900.75-1 /mssql-server-14.0.900.75-1.x86_64 870 MTransaction Summary===========================================================================================================================================================================Install 1 PackageTotal size: 870 MInstalled size: 870 MIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : mssql-server-14.0.900.75-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-14.0.900.75-1.x86_64 1/1 Installed: mssql-server.x86_64 0:14.0.900.75-1 Complete!
[root@linuxidc /opt/mssql/bin]# /opt/mssql/bin/mssql-conf setupThe license terms for this product can be found in/usr/share/doc/mssql-server or downloaded from:https://go.microsoft.com/fwlink/?LinkId=852741&clcid=0x409The privacy statement can be viewed at:https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409Do you accept the license terms? [Yes/No]:YESChoose 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) I bought a license through a retail sales channel and have a product key to enter.Details about editions can be found athttps://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409Use of PAID editions of this software requires separate licensing through aMicrosoft Volume Licensing program.By choosing a PAID edition, you are verifying that you have the appropriatenumber of licenses in place to install and run this software.Enter your edition(1-7): 2Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password: Configuring SQL Server...This is an evaluation version. There are [40] days left in the evaluation period.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@linuxidc /opt/mssql/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 Thu 2017-12-14 18:25:03 CST; 1min 23s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 56504 (sqlservr) CGroup: /system.slice/mssql-server.service ├─56504 /opt/mssql/bin/sqlservr └─56525 /opt/mssql/bin/sqlservrDec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.36 Server Server is listening on [ ::1 1434].Dec 14 18:25:10 linuxidc sqlservr[56504]: 2017-12-14 18:25:10.37 Server Server is listening on [ 127.0.0.1
wget https://packages.microsoft.com/rhel/7.3/prod/msodbcsql-13.1.6.0-1.x86_64.rpm wget https://packages.microsoft.com/rhel/7.3/prod/mssql-tools-14.0.5.0-1.x86_64.rpm
yum localinstall msodbcsql-13.1.6.0-1.x86_64.rpmyum localinstall mssql-tools-14.0.5.0-1.x86_64.rpm
[root@linuxidc /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"'>> ~/.bash_profile[root@linuxidc /opt]# source ~/.bash_profile [root@linuxidc /opt]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"'>> ~/.bashrc[root@linuxidc /opt]# source ~/.bashrc
[root@linuxidc /opt/mssql/bin]# sqlcmd -S localhost -U saPassword: 1> select name from sys.databases;2> goname --------------------------------------------------------------------------------------------------------------------------------master tempdb model msdb (5 rows affected)1> 1>create database TestDB;2>go1>1> use TestDB;2> goChanged database context to 'TestDB'.1> create table t1 (id int, cname nvarchar(50))2> go1> 1> insert into t1 (id, cname) values (1,'abc');2> go(1 rows affected)1> select * from t1;2> goid cname ----------- -------------------------------------------------- 1 abc (1 rows affected)1>
1> quit
[root@linuxidc /opt/sqlserver2017]# yum localinstall mssql-server-agent-14.0.900.75-1.x86_64.rpm Loaded plugins: fastestmirror, langpacksRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationExamining mssql-server-agent-14.0.900.75-1.x86_64.rpm: mssql-server-agent-14.0.900.75-1.x86_64Marking mssql-server-agent-14.0.900.75-1.x86_64.rpm to be installedResolving Dependencies--> Running transaction check---> Package mssql-server-agent.x86_64 0:14.0.900.75-1 will be installed--> Finished Dependency ResolutionDependencies Resolved=========================================================================================================================================================================== Package Arch Version Repository Size===========================================================================================================================================================================Installing: mssql-server-agent x86_64 14.0.900.75-1 /mssql-server-agent-14.0.900.75-1.x86_64 8.9 MTransaction Summary===========================================================================================================================================================================Install 1 PackageTotal size: 8.9 MInstalled size: 8.9 MIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : mssql-server-agent-14.0.900.75-1.x86_64 1/1 +--------------------------------------------------------------------------------+Please restart mssql-server to enable Microsoft SQL Server Agent.+--------------------------------------------------------------------------------+ Verifying : mssql-server-agent-14.0.900.75-1.x86_64 1/1 Installed: mssql-server-agent.x86_64 0:14.0.900.75-1 Complete!
Figure-1:SSMS 连接 Linux 下的数据库
Figure-2:查询版本信息
- SELECT @@VERSION;
- GO
- Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)
- Jul 27 2017 08:53:49
- Copyright (C) 2017 Microsoft Corporation
- Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))
Figure-3:查询数据发现 Red Gate 部分功能不能使用。rpm 包安装无法指定安装目录。
https://www.microsoft.com/en-us/sql-server/sql-server-2017 https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-red-hat https://packages.microsoft.com/rhel/7/mssql-server/ https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-troubleshooting-guide
来源: http://www.linuxidc.com/Linux/2017-12/149607.htm