码迷,mamicode.com
首页 > 数据库 > 详细

MSSQL Server 命令行工具 for Linux

时间:2019-05-20 13:50:50      阅读:879      评论:0      收藏:0      [点我收藏+]

标签:连接数   http   str   命令   set   class   too   xxx   -o   

1、添加安装源

[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 104 0 0:00:01 0:00:01 --:--:-- 104
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo msprod.repo mssql-server.repo

 

2、安装 mssql-tools 和 unixODBC 开发人员包

[root@localhost yum.repos.d]# yum install mssql-tools unixODBC-devel

3、将 /opt/mssql-tools/bin/ 添加到 PATH 环境变量

[root@localhost /]# echo export PATH="$PATH:/opt/mssql-tools/bin" >> ~/.bash_profile
[root@localhost /]# echo export PATH="$PATH:/opt/mssql-tools/bin" >> ~/.bashrc
[root@localhost /]# cd ~
[root@localhost ~]# source .bashrc 

 4、检查是否安装成功:输入命令 sqlcmd

[root@localhost opt]# sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 17.3.0000.1 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]
[root@localhost opt]# 

5、Centos 连接数据库:
  使用 SQL Server 名称 (-S),用户名 (-U) 和密码 (-P) 的参数运行 sqlcmd。 在本教程中,用户进行本地连接,因此服务器名称为 localhost。 用户名为 SA,密码是在安装过程中为 SA 帐户提供的密码。
  sqlcmd -S localhost -U SA -P ‘<YourPassword>‘
[root@localhost opt]# sqlcmd -S localhost -U sa -P xxxxxxxxxx
1>

 

 

 

MSSQL Server 命令行工具 for Linux

标签:连接数   http   str   命令   set   class   too   xxx   -o   

原文地址:https://www.cnblogs.com/ecsdoc/p/10893369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!