在 Linux 上安装 sqlcmd 和 bcp SQL Server 命令行工具Install sqlcmd and bcp the SQL Server command-line tools on Linux
06/30/2020
本文内容
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) - Linux适用于:Applies to: SQL ServerSQL Server(所有支持的版本)SQL ServerSQL Server (all supported versions) - Linux
通过以下步骤安装命令行工具、Microsoft ODBC 驱动程序及其依赖项。The following steps install the command-line tools, Microsoft ODBC drivers, and their dependencies. mssql-tools 包包含:The mssql-tools package contains:
sqlcmd:命令行查询实用工具。sqlcmd: Command-line query utility.
bcp:批量导入-导出实用工具。bcp: Bulk import-export utility.
为你的平台安装工具:Install the tools for your platform:
本文介绍如何安装命令行工具。This article describes how to install the command-line tools. 如果正在寻找有关如何使用 sqlcmd 或 bcp 的示例,请参阅本主题末尾的链接。If you are looking for examples of how to use sqlcmd or bcp, see the links at the end of this topic.
在 RHEL 8 上安装工具Install tools on RHEL 8
通过以下步骤在 Red Hat Enterprise Linux 上安装 mssql-tools。Use the following steps to install the mssql-tools on Red Hat Enterprise Linux.
进入超级用户模式。Enter superuser mode.
sudo su
下载 Microsoft Red Hat 存储库配置文件。Download the Microsoft Red Hat repository configuration file.
curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/msprod.repo
退出超级用户模式。Exit superuser mode.
exit
如果安装了早期版本的 mssql-tools,请删除所有旧的 unixODBC 包。If you had a previous version of mssql-tools installed, remove any older unixODBC packages.
sudo yum remove mssql-tools unixODBC-utf16-devel
运行以下命令,以使用 unixODBC 开发人员包安装 mssql-tools。Run the following commands to install mssql-tools with the unixODBC developer package.
sudo yum install mssql-tools unixODBC-devel
备注
若要将 mssql-tools 更新至最新版本,请运行以下命令:To update to the latest version of mssql-tools run the following commands:
sudo yum check-update
sudo yum update mssql-tools
可选:向 bash shell 中的 PATH 环境变量添加 /opt/mssql-tools/bin/。Optional: Add /opt/mssql-tools/