Linux下安装SQL Server 2016(连接篇SQL Server on linux)
连接数据库
(1)设置防火墙
要连接数据库,首先要打开防火墙上1433端口,也就是,增加tcp端口1433到公共区域,并且永久生效。
- [root@localhost Desktop]# firewall-cmd --zone=public --add-port=1433/tcp --permanent
- success
- [root@localhost Desktop]# firewall-cmd --reload
- success
(2)下载客户端工具的源、安装客户端工具
可以参考这个文章:安装sql server的客户端工具
也是非常简单的,先下载,然后安装。
- [root@localhost Desktop]# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
- % Total % Received % Xferd Average Speed Time Time Time Current
- Dload Upload Total Spent Left Speed
- 100 193 100 193 0 0 106 0 0:00:01 0:00:01 --:--:-- 106
- [root@localhost Desktop]# yum install -y mssql-tools
- Loaded plugins: fastestmirror, langpacks
- packages-microsoft-com-prod | 2.9 kB 00:00:00
- packages-microsoft-com-prod/primary_db | 4.6 kB 00:00:01
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.163.com
- Resolving Dependencies
- --> Running transaction check
- ---> Package mssql-tools.x86_64 0:14.0.1.246-1 will be installed
- --> Processing Dependency: msodbcsql for package: mssql-tools-14.0.1.246-1.x86_64
- --> Running transaction check
- ---> Package msodbcsql.x86_64 0:13.0.1.0-1 will be installed
- --> Processing Dependency: unixODBC-utf16 for package: msodbcsql-13.0.1.0-1.x86_64
- --> Processing Dependency: libodbcinst.so.2()(64bit) for package: msodbcsql-13.0.1.0-1.x86_64
- --> Running transaction check
- ---> Package unixODBC-utf16.x86_64 0:2.3.1-1 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ===========================================================================================================================
- Package Arch Version Repository Size
- ===========================================================================================================================
- Installing:
- mssql-tools x86_64 14.0.1.246-1 packages-microsoft-com-prod 249 k
- Installing for dependencies:
- msodbcsql x86_64 13.0.1.0-1 packages-microsoft-com-prod 3.8 M
- unixODBC-utf16 x86_64 2.3.1-1 packages-microsoft-com-prod 329 k
- Transaction Summary
- ===========================================================================================================================
- Install 1 Package (+2 Dependent packages)
- Total download size: 4.4 M
- Installed size: 4.4 M
- Downloading packages:
- (1/3): mssql-tools-14.0.1.246-1.x86_64.rpm | 249 kB 00:00:03
- (2/3): unixODBC-utf16-2.3.1-1.x86_64.rpm | 329 kB 00:00:01
- (3/3): msodbcsql-13.0.1.0-1.x86_64.rpm | 3.8 MB 00:00:21
- ---------------------------------------------------------------------------------------------------------------------------
- Total 211 kB/s | 4.4 MB 00:00:21
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Installing : unixODBC-utf16-2.3.1-1.x86_64 1/3
- 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
- Please enter YES or NO
- Do you accept the license terms? (Enter YES or NO)
- YES
- Installing : msodbcsql-13.0.1.0-1.x86_64 2/3
- 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-1.x86_64 3/3
- Verifying : msodbcsql-13.0.1.0-1.x86_64 1/3
- Verifying : unixODBC-utf16-2.3.1-1.x86_64 2/3
- Verifying : mssql-tools-14.0.1.246-1.x86_64 3/3
- Installed:
- mssql-tools.x86_64 0:14.0.1.246-1
- Dependency Installed:
- msodbcsql.x86_64 0:13.0.1.0-1 unixODBC-utf16.x86_64 0:2.3.1-1
- Complete!
(3)连接sql sever
这里用sqlcmd来连接sql server,下面是一些命令行参数。
- [root@localhost Desktop]# sqlcmd
- Microsoft (R) SQL Server Command Line Tool
- Version 14.0.0001.246 Linux
- Copyright (c) 2012 Microsoft. All rights reserved.
- usage: sqlcmd [-U login id] [-P password]
- [-S server or Dsn if -D is provided]
- [-H hostname] [-E trusted connection]
- [-N Encrypt Connection][-C Trust Server Certificate]
- [-d use database name] [-l login timeout] [-t query timeout]
- [-h headers] [-s colseparator] [-w screen width]
- [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
- [-c cmdend]
- [-q "cmdline query"] [-Q "cmdline query" and exit]
- [-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
- [-u unicode output] [-r[0|1] msgs to stderr]
- [-i inputfile] [-o outputfile]
- [-k[1|2] remove[replace] control characters]
- [-y variable length type display width]
- [-Y fixed length type display width]
- [-p[1] print statistics[colon format]]
- [-R use client regional setting]
- [-K application intent]
- [-M multisubnet failover]
- [-b On error batch abort]
- [-D Dsn flag, indicate -S is Dsn]
- [-X[1] disable commands, startup script, environment variables [and exit]]
- [-x disable variable substitution]
- [-? show syntax summary]
这里的-S是指定服务器名称,-U指定用户名,回车后会提示输入密码。
接下来查询当前是哪个库、创建了一个叫test的库、创建了一个叫tb的表、查询tb表的记录数。
- [root@localhost Desktop]# sqlcmd -S localhost -U sa
- Password:
- 1> select db_name();
- 2> go
- --------------------------------------------------------------------------------------------------------------------------------
- master
- (1 rows affected)
- 1> create database test;
- 2> go
- 1> use test;
- 2> go
- Changed database context to 'test'.
- 1> select * into tb from sys.tables;
- 2> go
- (1 rows affected)
- 1> select count(*) from tb;
- 2> go
- -----------
- 1
- (1 rows affected)
- 1>
(4)在windows上用Microsoft SQL Server Management Studio(ssms)连接
连接上sql server,查询表tb的数据。
另外,可以在Linux中查询当前连接到sql server的会话,发现有sqlcmd命令,还有ssms,在看看hostprocess进程号就是3228.
- 顶
- 0
- 踩
- 0
Linux下安装SQL Server 2016(连接篇SQL Server on linux)的更多相关文章
- Linux下安装MySQL及远程连接MySQL
安装方式一:通过下载官方安装包安装 由于Linux安装MySQL会遇到各种依赖问题,本博文整理了下安装方放,避免遇到依赖问题 查看是否自带mariadbrpm -qa|grep mariadb然后卸载 ...
- linux下安装nginx后开机启动篇
众所周知nginx安装后需要手动去启动,每次开机之后都要执行nginx的启动命令很蛋疼.那么我们来让nginx开机启动吧 1.先創建一個nginx文件把 [root@localhost ~]# vi ...
- linux 下安装ftp 并远程连接
1.确认是否已安装 ftp 1 pgrep vsftpd #查看ftp 服务进程 无结果如下图所示 2.执行安装 1 yum install vsftpd #安装ftp 服务 3.执行过程 ...
- (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记
Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...
- 如何在Linux下安装Tomcat
上篇文章写到了Linux下安装JDK1.8,这篇文章详细阐述一下 如何在Linux下安装Tomcat!!!有啥问题可以留言,博主每天都会看博客的. 准备步骤和方法和以前一样,博主用的工具是XShell ...
- Linux下安装Tomcat服务器
Linux下安装Tomcat服务器 一.总结 一句话总结: linux多用才能熟 1.阿里云上面我们买的服务器,怎么让它可以访问特定的端口? 就是给服务器的安全组添加规则:实例-->更多--&g ...
- Linux下安装与使用本地的perl模块
转自 http://www.cnblogs.com/xianghang123/archive/2012/08/23/2652806.html Linux下安装与使用本地的perl模块 在使用Linux ...
- linux下安装SlickEdit
title: linux下安装SlickEdit tags: 软件 date: 2018-10-08 21:32:12 --- linux下安装SlickEdit 下载安装包和补丁文件 补丁文件 官方 ...
- linux下安装Oracle时交换空间不足的解决方法
摘:linux下安装Oracle时交换空间不足的解决方法 linux上安装Oracle时交换空间不足的解决办法 增加交换空间有两种方法: 严格的说,在系统安装完后只有一种方法可以增加swap,那就是本 ...
- Linux下安装GB2312的示例
Linux下安装GB2312的示例 Step 1: 到Linux字符集的安装包目录下 [cd /usr/share/i18n/charmaps] Step 2: 解压该目录下的GB2312.gz ...
随机推荐
- UvaOJ 10167
暴力搜索 #include<cstdio> struct node { int x; int y; }s[]; int main() { //freopen("input.txt ...
- eclipse 离线安装插件报cannot perform operation.Computing alternate solutions...解决办法
当不能连接外网,离线安装SVN插件时,可能会发现以下问题:eclipse长时间停留在下图所示状态,提示“cannot perform operation.Computing alternate sol ...
- MySQL--Percona-XtraDB-Cluster 5.6安装笔记
安装环境: 有三台干净的CentOS 6的服务器,IP配置为:192.168.166.169,192.168.166.170,192.168.166.171,准备搭建三节点的Percona XtraD ...
- ue4开发入门教程
ue4是一套开源跨平台的游戏引擎,游戏画质3A水准,具有强大的材质编辑器,各种插件齐全.想要学习ue4的,可以参考这篇文章作为入门. 学习这篇文章,建议具有一定的C++基础,对游戏有一定了解. 1.首 ...
- 也来谈一谈js的浅复制和深复制
1.浅复制VS深复制 本文中的复制也可以称为拷贝,在本文中认为复制和拷贝是相同的意思.另外,本文只讨论js中复杂数据类型的复制问题(Object,Array等),不讨论基本数据类型(null,unde ...
- “全栈2019”Java多线程第三十四章:超时自动唤醒被等待的线程
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java多 ...
- jQuery中FormData的使用
web中数据提交事件是常常发生的,但是大多数情况下我们不希望使用html中的form表单提交,因为form表单提交会中断当前浏览器的操作并且会调到另一个地址(即使这个地址是当前页面),并且会重复加载一 ...
- C++ 设置Java 环境变量完整的例子
#include <stdio.h> #include <stdlib.h> #include <windows.h> #include <iostream& ...
- Linux学习笔记-基本操作2
1. 压缩包管理2. 进程管理3. 网路管理4. ftp服务器搭建5. nfs服务器搭建6. ssh服务器7. scp命令8. 其他命令9. 关机重启 1. 压缩包管理 1>. 屌丝版:不能对目 ...
- pip指定网址安装
用pip安装库的有时候很慢都动不了 ,访问速度很慢,不稳定等缺陷 所以呢为了解决这个问题只能指定网址源下载的话速度就很快了 pip安装默认访问的是https://pypi.Python.org/sim ...