学习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 ...
随机推荐
- SDWebImage第三方库学习
1.基本使用方法 //异步下载并缓存 - (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; //使用占位图片,当 ...
- MongoDB快速入门(六)- 更新文档
更新文档 MongoDB的update()和save()方法用于更新文档到一个集合. update()方法将现有的文档中的值更新,而save()方法使用传递到save()方法的文档替换现有的文档. M ...
- yum 源配置
在 /etc/yum.repos.d 下建立一个 .repo 文件 vim yum.repo [cd] name=cd baseurl=file:///run/media/root/RHEL-7.0 ...
- 网络最大流的(Edmond Karp)算法
容量网络:在有向图D=(V,A),指定一个点为发点,记作 s,指定另一个点为收点,记作 t,其余点叫作中间点.对于A的每条弧(Vi,Ai),都对应一个权数 C ≥0,称为弧(Vi , Ai)的容量,将 ...
- HDU 5037 Frog(2014年北京网络赛 F 贪心)
开始就觉得有思路,结果越敲越麻烦... 题意很简单,就是说一个青蛙从0点跳到m点,最多可以跳l的长度,原有石头n个(都仅表示一个点).但是可能跳不过去,所以你是上帝,可以随便在哪儿添加石头,你的策略 ...
- cdq分治入门and持续学习orz
感觉cdq分治是一个很有趣的算法 能将很多需要套数据结构的题通过离线来做 目前的一些微小的理解 在一般情况下 就像求三维偏序xyz 就可以先对x排序 然后分治 1 cdq_x(L,M) ; 2 提取出 ...
- 汇编笔记 RETF
assume cs:code stack segment db 16 dup(0) stack ends code segment start: mov ax,stack;将定义字形数据送入AX mo ...
- Codeforces Round #373 (Div. 2) E. Sasha and Array 矩阵快速幂+线段树
E. Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard ...
- jquery事件优化---事件委托
假如你有一个表格,里面有大量的td 而你需要做的事就是,给td绑定点击事件函数, 那么多的td,遍历单元格和为每一个单元格绑定事件处理函数将会大大降低代码的性能, 如果让单元格的父元素监听事件,只要判 ...
- review37
线程的常用方法 1.start() 线程调用该方法将启动线程,使之从新建状态进入就绪队列排队. 2.run() 3.sleep() 4.isAlive() 线程处于新建状态时,线程调用isAlive( ...