学习SQL Server从在Linux上安装开始
微软已经发布了SQL Server on Linux,目前支持Redhat和Ubuntu两种发行版。
下面我们来安装体验一下。
1. 获得YUM源:
YUM的repo文件地址:
https://packages.microsoft.com/config/rhel/7/mssql-server.repo
下载到本地:
wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo
---- ::-- https://packages.microsoft.com/config/rhel/7/mssql-server.repo
Resolving packages.microsoft.com (packages.microsoft.com)... 13.75.127.55
Connecting to packages.microsoft.com (packages.microsoft.com)|13.75.127.55|:... connected.
HTTP request sent, awaiting response... OK
Length: [application/octet-stream]
Saving to: 'mssql-server.repo'
%[=================================================================================================================================>] --.-K/s in 0s
-- :: (47.7 MB/s) - 'mssql-server.repo' saved [/]
把此文件复制到/etc/yum.repos.d目录:
cp mssql-server.repo /etc/yum.repos.d/
更新yum信息:
[root@hwweb0 ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB ::
extras | 3.4 kB ::
openlogic | 1.3 kB ::
packages-microsoft-com-mssql-server | 2.9 kB ::
updates | 3.4 kB ::
(/): extras//x86_64/prestodelta | kB ::
(/): openlogic//x86_64/filelists | 6.7 kB ::
(/): openlogic//x86_64/other | 3.7 kB ::
(/): extras//x86_64/filelists_db | kB ::
(/): extras//x86_64/other_db | kB ::
(/): packages-microsoft-com-mssql-server/filelists_db | 1.4 kB ::
(/): packages-microsoft-com-mssql-server/other_db | B ::
(/): base//x86_64/other_db | 2.3 MB ::
(/): updates//x86_64/prestodelta | kB ::
(/): updates//x86_64/filelists_db | 5.3 MB ::
(/): base//x86_64/filelists_db | 6.2 MB ::
(/): updates//x86_64/other_db | MB ::
(/): packages-microsoft-com-mssql-server/primary_db | 2.4 kB ::
Loading mirror speeds from cached hostfile
openlogic /
openlogic /
Metadata Cache Created
2. 通过yum安装sql server:
Yum查找mssql的相关信息:
[root@hwweb0 ~]# yum search mssql
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
Loading mirror speeds from cached hostfile
=========================================================================== N/S matched: mssql ============================================================================
mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
Name and summary matches only, use "search all" for everything.
可以看到有两个版本,ha版本应该是做高可用性的版本。安装mssql-server:
[root@hwweb0 ~]# yum search mssql
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
Loading mirror speeds from cached hostfile
=========================================================================== N/S matched: mssql ============================================================================
mssql-server.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
mssql-server-ha.x86_64 : Microsoft(R) SQL Server(R) Relational Database Engine
Name and summary matches only, use "search all" for everything.
[root@hwweb0 ~]# yum install mssql-server -y
Loaded plugins: fastestmirror, langpacks
Repository packages-microsoft-com-mssql-server is listed more than once in the configuration
packages-microsoft-com-mssql-server | 2.9 kB ::
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 :14.0.1.246- will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
mssql-server x86_64 14.0.1.246- packages-microsoft-com-mssql-server M
Transaction Summary
===========================================================================================================================================================================
Install Package
Total download size: M
Installed size: M
Downloading packages:
warning: /var/cache/yum/x86_64//packages-microsoft-com-mssql-server/packages/mssql-server-14.0.1.246-.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-14.0.1.246-.x86_64.rpm is not installed
mssql-server-14.0.1.246-.x86_64.rpm | MB ::
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
Userid : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
Fingerprint: bc52 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.1.246-.x86_64 /
+-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
| Microsoft(R) SQL Server(R). |
+-------------------------------------------------------------------+
Verifying : mssql-server-14.0.1.246-.x86_64 /
Installed:
mssql-server.x86_64 :14.0.1.246-
Complete!
这样就安装好了。
3. 配置sql server
[root@hwweb0 bin]# pwd
/opt/mssql/bin
[root@hwweb0 bin]# ./sqlservr-setup
Microsoft(R) SQL Server(R) Setup
You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode.
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT.
Do you accept the license terms? If so, please type "YES": YES
Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:
Setting system administrator (SA) account password...
sqlservr: This program requires a machine with at least megabytes of memory.
Microsoft(R) SQL Server(R) setup failed with error code .
Please check the setup log in /var/opt/mssql/log/setup--.log
for more information.
我采用的是A1的机器,配置过程提示,内存需要大于3G。把机器升级到A2:
[root@hwchefserver bin]# ./sqlservr-setup
Microsoft(R) SQL Server(R) Setup
You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode.
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT.
Do you accept the license terms? If so, please type "YES": YES
Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:
Setting system administrator (SA) account password...
Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service to /usr/lib/systemd/system/mssql-server-telemetry.service.
Setup completed successfully.
配置成功。检查状态:
[root@hwchefserver bin]# systemctl status mssql
● mssql.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@hwchefserver bin]# systemctl status mssql-server
● mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
Active: active (running) since Thu -- :: UTC; 37s ago
Main PID: (sqlservr)
CGroup: /system.slice/mssql-server.service
├─ /opt/mssql/bin/sqlservr
└─ /opt/mssql/bin/sqlservr
Nov :: hwchefserver sqlservr[]: -- ::15.06 spid17s SQL Server is now ready for client connections. This is an infor...equired.
Nov :: hwchefserver sqlservr[]: -- ::15.13 spid6s Polybase feature disabled.
Nov :: hwchefserver sqlservr[]: -- ::15.13 spid6s Clearing tempdb database.
Nov :: hwchefserver sqlservr[]: -- ::16.91 spid6s Starting up database 'tempdb'.
Nov :: hwchefserver sqlservr[]: -- ::17.58 spid6s The tempdb database has data file(s).
Nov :: hwchefserver sqlservr[]: -- ::17.58 spid20s The Service Broker endpoint is in disabled or stopped state.
Nov :: hwchefserver sqlservr[]: -- ::17.58 spid20s The Database Mirroring endpoint is in disabled or stopped state.
Nov :: hwchefserver sqlservr[]: -- ::17.67 spid20s Service Broker manager has started.
Nov :: hwchefserver sqlservr[]: -- ::17.71 spid5s Recovery is complete. This is an informational message only. No ...equired.
Nov :: hwchefserver sqlservr[]: -- ::22.59 spid35s The activated proc '[dbo].[sp_syspolicy_events_reader]' running on queue...
Hint: Some lines were ellipsized, use -l to show in full.
SQL Server已经在运行。
3. 检查
安装SQL Tools。SQL Tools:sqlcmd是mssql ODBC的一个工具,可以通过yum的repo直接yum安装。
首先下载yum的repo:
[root@hwchefserver ~]# wget https://packages.microsoft.com/config/rhel/7/prod.repo
---- ::-- https://packages.microsoft.com/config/rhel/7/prod.repo
Resolving packages.microsoft.com (packages.microsoft.com)... 13.75.127.55
Connecting to packages.microsoft.com (packages.microsoft.com)|13.75.127.55|:... connected.
HTTP request sent, awaiting response... OK
Length: [application/octet-stream]
Saving to: 'prod.repo'
%[=================================================================================================================>] --.-K/s in 0s
-- :: (30.2 MB/s) - 'prod.repo' saved [/]
[root@hwchefserver ~]# mv prod.repo /etc/yum.repos.d/
[root@hwchefserver ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB ::
extras | 3.4 kB ::
openlogic | 1.3 kB ::
packages-microsoft-com-mssql-server | 2.9 kB ::
packages-microsoft-com-prod | 2.9 kB ::
updates | 3.4 kB ::
(/): packages-microsoft-com-prod/filelists_db | 2.7 kB ::
(/): packages-microsoft-com-prod/other_db | kB ::
(/): packages-microsoft-com-prod/primary_db | 4.6 kB ::
Loading mirror speeds from cached hostfile
Metadata Cache Created
安装:
[root@hwchefserver ~]# yum install mssql-tools
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 :14.0.1.246- will be installed
--> Processing Dependency: msodbcsql for package: mssql-tools-14.0.1.246-.x86_64
--> Running transaction check
---> Package msodbcsql.x86_64 :13.0.1.0- will be installed
--> Processing Dependency: unixODBC-utf16 for package: msodbcsql-13.0.1.0-.x86_64
--> Processing Dependency: libodbcinst.so.()(64bit) for package: msodbcsql-13.0.1.0-.x86_64
--> Running transaction check
---> Package unixODBC-utf16.x86_64 :2.3.- will be installed
--> Processing Dependency: libltdl.so.()(64bit) for package: unixODBC-utf16-2.3.-.x86_64
--> Running transaction check
---> Package libtool-ltdl.x86_64 :2.4.-.el7_2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================
Installing:
mssql-tools x86_64 14.0.1.246- packages-microsoft-com-prod k
Installing for dependencies:
libtool-ltdl x86_64 2.4.-.el7_2 updates k
msodbcsql x86_64 13.0.1.0- packages-microsoft-com-prod 3.8 M
unixODBC-utf16 x86_64 2.3.- packages-microsoft-com-prod k
Transaction Summary
===========================================================================================================================================================
Install Package (+ Dependent packages)
Total download size: 4.5 M
Installed size: 4.5 M
Is this ok [y/d/N]: y
Downloading packages:
(/): libtool-ltdl-2.4.-.el7_2.x86_64.rpm | kB ::
(/): msodbcsql-13.0.1.0-.x86_64.rpm | 3.8 MB ::
(/): mssql-tools-14.0.1.246-.x86_64.rpm | kB ::
(/): unixODBC-utf16-2.3.-.x86_64.rpm | kB ::
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.3 MB/s | 4.5 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libtool-ltdl-2.4.-.el7_2.x86_64 /
Installing : unixODBC-utf16-2.3.-.x86_64 /
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746838 and found in
/usr/share/doc/msodbcsql/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 : msodbcsql-13.0.1.0-.x86_64 /
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-14.0.1.246-.x86_64 /
Verifying : libtool-ltdl-2.4.-.el7_2.x86_64 /
Verifying : msodbcsql-13.0.1.0-.x86_64 /
Verifying : unixODBC-utf16-2.3.-.x86_64 /
Verifying : mssql-tools-14.0.1.246-.x86_64 /
Installed:
mssql-tools.x86_64 :14.0.1.246-
Dependency Installed:
libtool-ltdl.x86_64 :2.4.-.el7_2 msodbcsql.x86_64 :13.0.1.0- unixODBC-utf16.x86_64 :2.3.-
Complete!
安装成功!
测试连接:
[root@hwchefserver ~]# sqlcmd -S localhost -U SA
Password:
登陆成功。
创建数据库test:
> create database test;
> go
> use test;
> go
Changed database context to 'test'.
查看数据库:
> select name from sys.databases;
> go
name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb
test
创建表hwtable:
> create table hwtable ( id int, name varchar(), gender varchar(), age int);
> go
插入数据:
> insert into hwtable values (, 'weiheng','male',);
> go
查询:
> select * from hwtable;
> go
id name gender age
----------- -------------------- -------------------- -----------
weiheng male
( rows affected)
MSSQL Sever On Linux就这样安装完成了!
学习SQL Server从在Linux上安装开始的更多相关文章
- SQL Server on Ubuntu——Ubuntu上的SQL Server(全截图)
本文从零开始一步一步介绍如何在Ubuntu上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一. 创建Ubuntu系统(Create U ...
- 在linux上安装 sql server for linux
在linux上安装 sql server for linux Install SQL Server on Red Hat Enterprise Linux Install SQL Server To ...
- 【BI学习笔记】在Linux上安装Wyn Enterprise商业智能报表服务器
在百度文库上找来的,放到这里,避免以后丢了. 葡萄城出品的Wyn Enterprise商业智能软件的设计器和查看视图是通过浏览器使用的,不需要安装专门的程序.Wyn Enterprise的服务器端可以 ...
- Configure Always On Availability Group for SQL Server on Ubuntu——Ubuntu上配置SQL Server Always On Availability Group
下面简单介绍一下如何在Ubuntu上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 目前在Linux上可以搭 ...
- 怎样在 Ubuntu Linux 上安装 MySQL
本教程教你如何在基于 Ubuntu 的 Linux 发行版上安装 MySQL.对于首次使用的用户,你将会学习到如何验证你的安装和第一次怎样去连接 MySQL. -- Sergiu MySQL 是一个典 ...
- linux上安装配置samba服务器
linux上安装配置samba服务器 在linux上安装配置samba服务器 在这给大家介绍一个不错的家伙,samba服务.如果您正在犯愁,如何在Windows和Linux之间实现资源共享,就请看看这 ...
- 在Windows和Linux上安装paramiko模块以及easy_install的安装方法
一.paramiko模块有什么用? paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接.由于使用的是python这样的能够跨平台运行的语言 ...
- Sql Server 2008卸载后再次安装一直报错
sql server 2008卸载之后再次安装一直报错问题. 第一:由于上一次的卸载不干净,可参照百度完全卸载sql server2008 的方式 1. 用WindowsInstaller删除所有与S ...
- 在Linux上安装Oracle RAC 12 c(12.1) 虚拟机,一步一步向导
Oracle RAC 12 c(12.1)在Linux上安装虚拟机,一步一步向导 今天我们将看到如何安装 12 c版本1 RAC(真正的应用程序集群)数据库2 Linux 64位的虚拟机 使用VMWa ...
随机推荐
- 案例:1 Ionic Framework+AngularJS+ASP.NET MVC WebApi Jsonp 移动开发
落叶的庭院扫的一干二净之后,还要轻轻把树摇一下,抖落几片叶子,这才是Wabi Sabi的境界. 介绍:Ionic是移动框架,angularjs这就不用说了,ASP.Net MVC WebApi提供数据 ...
- awk中的常用关于处理字符串的函数
1.替换字符串中的某一部分. 函数:gensub(/rexpr/,"replace","g","string"),gensub返回一个新的字 ...
- php面向对象之克隆对象
在前面的PHP面向对象之对象和引用,我们试图以"$b=$a"的方式复制对象以传递对象的值(内容),结果却是传递对象的地址,在结尾为了解决复制对象这个问题,提到了克隆的方法.接下来讲 ...
- 字符串处理sdut 2411
题目:http://www.sdutacm.org/sdutoj/problem.php?action=showproblem&problemid=2411 关于字符串处理的题,此题坑点很多w ...
- 小组E-R图的改进 2.0版本
上图是我对我们小组的数据库E-R图的改进 我在出勤上加了一个学生留言,因为我们组在需求分析中说明了有个教师与学生通过此软件交流的功能,教师可以通过这个功能给学生留言,学生也可以通过此功能请假或者说明旷 ...
- DataWarehouse- 从面试定位自己的水平
1.讲一下什么是维度表和事实表.用户资料表算是什么类型表. 2. 维度建模属于第几范式,让你对维度建模改进,有什么思路吗. 3. 了解数据血缘分析吗,让你实现的话有什么技术方案,感觉难点在哪. 4. ...
- python中set类型总结
set的创建无非有两种方式: 一 直接使用{}创建新的set并初始化 例如: set1 = {1,2,3,"good news",(1,2,3)} #声明的时候可以包含元组,但不能 ...
- 获得Version和Build版本号
[[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBu ...
- mac系统卸载mono
官方页面:http://www.mono-project.com/docs/about-mono/supported-platforms/osx/#uninstalling-mono-on-mac-o ...
- poj 1836 LIS变形
题目链接http://poj.org/problem?id=1836 Alignment Time Limit: 1000MS Memory Limit: 30000K Total Submiss ...