更新时间:2023-02-04 09:36:09
-S MY_SERVER_IP\ESB_WSO2_USER_DB
表示服务器的IP,实例的名称。 Windows主机可以运行多个SQL Server实例,并且当它们运行时,需要为后一个实例赋予与默认实例名称不同的名称( MSSQLSERVER
)并在另一个实例上运行港口。因此,您可以在以后指定名称,而不是端口(如果您正在运行命名服务器)。例如, SRVSQLHost\DevInstance
将连接到服务器 SRVSQLHost 服务器上的实例
DevInstance
。 code>; 不是主机上实例
。 MSSQLSERVER
上的数据库 DevInstance
SRVSQLHost
-S MY_SERVER_IP\ESB_WSO2_USER_DB
means the IP of the server, and the name of the instance. Windows Hosts can run multiple instances of SQL Server, and when they do, latter instances need to be given a different name to the default instance name (MSSQLSERVER
) and run on a different port. As a result you can specify the name afterwards, rather than the port (if you have named servers running). For example SRVSQLHost\DevInstance
would connect the to instance DevInstance
on the server SRVSQLHost
; not the database DevInstance
on the instance MSSQLSERVER
on the host SRVSQLHost
.
您可以使用 -d
开关传递数据库名称。如果仅运行 sqlcmd
(在Bash中,而在Powershell中,则需要使用 sqlcmd-?
),您将看到输入开关:
You pass the name of the database using the -d
switch. If you run simply sqlcmd
(in Bash, not Powershell, where you need to use sqlcmd -?
) you'll see the input switches:
:~$ sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 17.4.0001.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]
请注意,Windows Powershell上的某些开关在Bash和Linux的Powershell;
因此,对于您想要的东西:
So, for what you have you want:
sqlcmd -S MY_SERVER_IP -d ESB_WSO2_USER_DB -U YOUR_LOGIN_NAME
(I假设您需要通过 -U
开关,除非您在Ubuntu实例上配置了 kerboros,但是您没有提及它,所以我请注意, -U
的 LOGIN
必须是SQL身份验证登录名,而不是AD登录名。)
(I assume you need to pass the -U
switch, unless you have configured kerboros on your Ubuntu instance, but you didn't mention it, so I assumed not. Note that the LOGIN
for -U
must be a SQL Authentication login, not an AD login.)