mysql cmd 连接_使用 sqlcmd 连接到数据库引擎 - SQL Server Management Studio (SSMS) | Microsoft Docs...

本文介绍了如何使用sqlcmd工具通过TCP/IP、命名管道和共享内存协议连接到SQL Server数据库引擎。详细说明了连接默认实例和命名实例的命令行参数。
摘要由CSDN通过智能技术生成

sqlcmd - 连接到数据库引擎sqlcmd - Connect to the Database Engine

03/14/2017

本文内容

适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) 719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database 719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance 719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics 719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse适用于:Applies to: 719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server(所有支持的版本)719f28649793c602f9270966b5ed5c39.pngSQL ServerSQL Server (all supported versions) 719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database719f28649793c602f9270966b5ed5c39.pngAzure SQL 数据库Azure SQL Database 719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance719f28649793c602f9270966b5ed5c39.pngAzure SQL 托管实例Azure SQL Managed Instance 719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics719f28649793c602f9270966b5ed5c39.pngAzure Synapse AnalyticsAzure Synapse Analytics 719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse719f28649793c602f9270966b5ed5c39.png并行数据仓库Parallel Data Warehouse

SQL ServerSQL Server 支持客户端使用 TCP/IP 网络协议(默认)和命名管道协议进行通信。supports client communication with the TCP/IP network protocol (the default), and the named pipes protocol. 如果客户端正在连接到同一计算机上的数据库引擎Database Engine实例,则还可使用 Shared Memory 协议。The shared memory protocol is also available if the client is connecting to an instance of the 数据库引擎Database Engine on the same computer. 通常有三种选择协议的方法。There are three common methods of selecting the protocol. sqlcmd 实用工具使用的协议按下列顺序确定:The protocol used by the sqlcmd utility is determined in the following order:

sqlcmd 使用为连接字符串中指定的协议,如下所述。sqlcmd uses the protocol specified as part of the connection string as described below.

如果连接字符串中未指定任何协议,则 sqlcmd 将使用连接到的别名中定义的协议。If no protocol is specified as part the connection string, sqlcmd will use the protocol defined as part of the alias that it is connecting to.

如果未通过其他方法指定协议, sqlcmd 将使用由 SQL ServerSQL Server 配置管理器中的协议顺序确定的网络协议。If the protocol is not specified in some other way, sqlcmd will use the network protocol determined by the protocol order in SQL ServerSQL Server Configuration Manager.

下面的示例显示连接到 1433 端口上默认的 数据库引擎Database Engine 实例以及假定侦听 1691 端口的 数据库引擎Database Engine 命名实例的各种方法。The following examples show various ways of connecting to the default instance of 数据库引擎Database Engine on port 1433, and named instances of 数据库引擎Database Engine presumed to be listening on port 1691. 其中一些示例使用环回适配器的 IP 地址 (127.0.0.1)。Some of these examples use the IP address of the loopback adapter (127.0.0.1). 请使用您的计算机网络接口卡的 IP 地址进行测试。Test using the IP address of your computer network interface card.

通过指定实例名连接到 数据库引擎Database Engine :Connect to the 数据库引擎Database Engine by specifying the instance name:

sqlcmd -S ComputerA

sqlcmd -S ComputerA\instanceB

通过指定 IP 地址连接到 数据库引擎Database Engine :Connect to the 数据库引擎Database Engine by specifying the IP address:

sqlcmd -S 127.0.0.1

sqlcmd -S 127.0.0.1\instanceB

通过指定 TCP\IP 端口号连接到 数据库引擎Database Engine :Connect to the 数据库引擎Database Engine by specifying the TCP\IP port number:

sqlcmd -S ComputerA,1433

sqlcmd -S ComputerA,1691

sqlcmd -S 127.0.0.1,1433

sqlcmd -S 127.0.0.1,1691

使用 TCP/IP 进行连接To connect using TCP/IP

使用以下常规语法进行连接:Connect using the following general syntax:

sqlcmd -S tcp:,

连接到默认实例:Connect to the default instance:

sqlcmd -S tcp:ComputerA,1433

sqlcmd -S tcp:127.0.0.1,1433

连接到命名实例:Connect to a named instance:

sqlcmd -S tcp:ComputerA,1691

sqlcmd -S tcp:127.0.0.1,1691

使用命名管道进行连接To connect using named pipes

使用下列常规语法之一进行连接:Connect using one of the following general syntax:

sqlcmd -S np:\\\

连接到默认实例:Connect to the default instance:

sqlcmd -S np:\\ComputerA\pipe\sql\query

sqlcmd -S np:\\127.0.0.1\pipe\sql\query

连接到命名实例:Connect to a named instance instance:

sqlcmd -S np:\\ComputerA\pipe\MSSQL$\sql\query

sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$\sql\query

在服务器上从客户端使用共享内存(本地过程调用)进行连接To connect using shared memory (a local procedure call) from a client on the server

使用下列常规语法之一进行连接:Connect using one of the following general syntax:

sqlcmd -S lpc:

连接到默认实例:Connect to the default instance:

sqlcmd -S lpc:ComputerA

连接到命名实例:Connect to a named instance:

sqlcmd -S lpc:ComputerA\

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值