学习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 ...
随机推荐
- 快乐学习 Ionic Framework+PhoneGap 手册1-2{介绍Header,Content,Footer的使用}
*先运行第一个简单的APP,介绍Header,Content,Footer的使用 {2.1}运行一个简单的APP,效果如下 {2.2}Header代码 <ion-header-bar class ...
- 主攻ASP.NET MVC4.0之重生:发邮箱激活验证
导入Interop.jmail组件 using jmail;using System.Net.Mail; 点击下载源代码 Controller相关代码 public class SendEmailCo ...
- Eclipse与Tomcat的集成(无插件)
1.下载Eclipse(https://www.eclipse.org/downloads/)和Tomcat(http://tomcat.apache.org/),具体的安装略: 2.打开Eclips ...
- centos_mysql5.6.35_rpm安装
1.查看操作系统相关信息.[root@linuxidc ~]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m [root@l ...
- ubuntu 下使用vi时方向键乱码,退格键不能使用
ubuntu 下使用vi时方向键乱码,退格键不能使用的解决方法 问题表现:Ubuntu下,初始使用vi,编辑模式下使用方向键的时候,并不会使光标移动,而是在命令行中出现A B C D 之类的字母,并且 ...
- CentOS/Linux 卸载MATLAB
rm -rf /usr/local/MATLAB/R2012arm /usr/local/bin/matlab /usr/local/bin/mcc /usr/local/bin/mex /usr/l ...
- 【P2401】不等数列(DP)
这个题乍一看就应该是DP,再看一眼数据范围,1000..那就应该是了.然后就向DP的方向想,经过对小数据的计算可以得出,如果我们用f[i][j]来表示前i个数有j个是填了"<" ...
- ajax02-XMLHttpRequest 对象的使用
XMLHttpRequest 是 AJAX 的基础,用于在后台与服务器交换数据.这意味着可以在不重新加载整个网页的情况下,对网页的某部分进行更新. XMLHttpRequest 对象 所有现代浏览器均 ...
- 使用Navicat进行数据库自动备份
今天经历一次数据库丢库事件,顿时觉得定时备份数据库很重要. 但是每天自己手动备份实在是太麻烦了,于是乎,想到用计划任务进行每天定时自动备份. 发现Navicat自带就有备份 还可以直接计划任务,贼方 ...
- Aix-Linux查看系统信息
1.查看内存.磁盘等使用情况 命令:nmon 输入命令nmon之后,按M键memory,N键NetWork,J键查看目录使用情况. 2.查看防火墙 命令:smit 输入之后按照图形化操作 Commun ...