添加源:

debian源:deb [arch=amd64] https://packages.microsoft.com/debian/10/prod buster main

ubuntu源:deb [arch=amd64] https://packages.microsoft.com/ubuntu/19.04/prod disco main

apt install multiarch-support

wget http://ftp.cn.debian.org/debian/pool/main/j/jemalloc/libjemalloc1_3.6.0-3_amd64.deb

wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u11_amd64.deb

dpkg -i libjemalloc1_3.6.0-3_amd64.deb libssl1.0.0_1.0.1t-1+deb8u11_amd64.deb

 

安装 SQL ServerInstall SQL Server

要在 Ubuntu 上配置 SQL Server,请在终端中运行以下命令以安装 mssql-server 包  。To configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.

  1. 导入公共存储库 GPG 密钥:Import the public repository GPG keys:

    bash 复制
    wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  2. 注册 Microsoft SQL Server Ubuntu 存储库:Register the Microsoft SQL Server Ubuntu repository:

    bash 复制
    sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"

    提示

    如果想试用 SQL Server 2019,需改为注册预览版 (2019) 存储库  。If you want to try SQL Server 2019 , you must instead register the Preview (2019) repository. 使用以下命令安装 SQL Server 2019:Use the following command for SQL Server 2019 installations:

    bash 复制
    sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
  3. 运行以下命令以安装 SQL Server:Run the following commands to install SQL Server:

    bash 复制
    sudo apt-get update
    sudo apt-get install -y mssql-server
  4. 包安装完成后,运行 mssql-conf setup,按照提示设置 SA 密码并选择版本。After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.

    bash 复制
    sudo /opt/mssql/bin/mssql-conf setup

    提示

    以下 SQL Server 2017 版本是免费提供许可的:Evaluation、Developer 和 Express 版。The following SQL Server 2017 editions are freely licensed: Evaluation, Developer, and Express.

    备注

    请确保为 SA 帐户指定强密码(最少 8 个字符,包括大写和小写字母、十进制数字和/或非字母数字符号)。Make sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).

  5. 完成配置后,验证服务是否正在运行:Once the configuration is done, verify that the service is running:

    bash 复制
    systemctl status mssql-server --no-pager
  6. 如果计划远程连接,可能还需要在防火墙上打开 SQL Server TCP 端口(默认值为 1433)。If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.

此时,SQL Server 已在 Ubuntu 计算机上运行,随时可以使用!At this point, SQL Server is running on your Ubuntu machine and is ready to use!

安装 SQL ServerInstall SQL Server

要在 Ubuntu 上配置 SQL Server,请在终端中运行以下命令以安装 mssql-server 包  。To configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.

  1. 导入公共存储库 GPG 密钥:Import the public repository GPG keys:

    bash 复制
    wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  2. 为 SQL Server 2019(预览版)注册 Microsoft SQL Server Ubuntu 存储库:Register the Microsoft SQL Server Ubuntu repository for SQL Server 2019 preview:

    bash 复制
    sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
  3. 运行以下命令,安装 SQL Server:Run the following commands to install SQL Server:

    bash 复制
    sudo apt-get update
    sudo apt-get install -y mssql-server
  4. 包安装完成后,运行 mssql-conf setup,按照提示设置 SA 密码并选择版本。After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.

    bash 复制
    sudo /opt/mssql/bin/mssql-conf setup

    备注

    请确保为 SA 帐户指定强密码(最少 8 个字符,包括大写和小写字母、十进制数字和/或非字母数字符号)。Make sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).

  5. 完成配置后,验证服务是否正在运行:Once the configuration is done, verify that the service is running:

    bash 复制
    systemctl status mssql-server --no-pager
  6. 如果计划远程连接,可能还需要在防火墙上打开 SQL Server TCP 端口(默认值为 1433)。If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.

此时,SQL Server 2019(预览版)已在 Ubuntu 计算机上运行,随时可以使用!At this point, SQL Server 2019 preview is running on your Ubuntu machine and is ready to use!

安装 SQL Server 命令行工具Install the SQL Server command-line tools

若要创建数据库,则需要使用可在 SQL Server 上运行 Transact-SQL 语句的工具进行连接。To create a database, you need to connect with a tool that can run Transact-SQL statements on the SQL Server. 以下步骤安装 SQL Server 命令行工具:sqlcmd 和 bcp。The following steps install the SQL Server command-line tools: sqlcmd and bcp.

通过下列步骤在 Ubuntu 上安装 mssql-tools  。Use the following steps to install the mssql-tools on Ubuntu.

  1. 导入公共存储库 GPG 密钥。Import the public repository GPG keys.

    bash 复制
    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  2. 注册 Microsoft Ubuntu 存储库。Register the Microsoft Ubuntu repository.

    bash 复制
    curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
  3. 更新源列表,并使用 unixODBC 开发人员包运行安装命令。Update the sources list and run the installation command with the unixODBC developer package.

    bash 复制
    sudo apt-get update
    sudo apt-get install mssql-tools unixodbc-dev

    备注

    若要将 mssql-tools 更新至最新版本,请运行以下命令  :To update to the latest version of mssql-tools run the following commands:

    bash 复制
    sudo apt-get update
    sudo apt-get install mssql-tools
  4. 可选:向 bash shell 中的 PATH 环境变量添加 /opt/mssql-tools/bin/  。Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

    要使 sqlcmd/bcp 能从登陆会话的 bash shell 进行访问,请使用下列命令修改 ~/.bash_profile 文件中的 PATH    :To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

    bash 复制
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

    要使 sqlcmd/bcp 能从交互式/非登录会话的 bash shell 进行访问,请使用下列命令修改 ~/.bashrc 文件中的 PATH    :To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:

    bash 复制
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
    source ~/.bashrc

本地连接Connect locally

以下步骤使用 sqlcmd  本地连接到新的 SQL Server 实例。The following steps use sqlcmd to locally connect to your new SQL Server instance.

  1. 使用 SQL Server 名称 (-S),用户名 (-U) 和密码 (-P) 的参数运行 sqlcmd  。Run sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P). 在本教程中,用户进行本地连接,因此服务器名称为 localhost。In this tutorial, you are connecting locally, so the server name is localhost. 用户名为 SA,密码是在安装过程中为 SA 帐户提供的密码。The user name is SA and the password is the one you provided for the SA account during setup.

    bash 复制
    sqlcmd -S localhost -U SA -P '<YourPassword>'

    提示

    可以在命令行上省略密码,以收到密码输入提示。You can omit the password on the command line to be prompted to enter it.

    提示

    如果以后决定进行远程连接,请指定 -S  参数的计算机名称或 IP 地址,并确保防火墙上的端口 1433 已打开。If you later decide to connect remotely, specify the machine name or IP address for the -S parameter, and make sure port 1433 is open on your firewall.

  2. 如果成功,应会显示 sqlcmd  命令提示符:1>。If successful, you should get to a sqlcmd command prompt: 1>.

  3. 如果连接失败,先尝试诊断错误消息中所述的问题。If you get a connection failure, first attempt to diagnose the problem from the error message. 然后查看连接故障排除建议。Then review the connection troubleshooting recommendations.

创建和查询数据Create and query data

下面各部分将逐步介绍如何使用 sqlcmd  新建数据库、添加数据并运行简单查询。The following sections walk you through using sqlcmd to create a new database, add data, and run a simple query.

新建数据库Create a new database

以下步骤创建一个名为 TestDB 的新数据库。The following steps create a new database named TestDB.

  1. 在 sqlcmd  命令提示符中,粘贴以下 Transact-SQL 命令以创建测试数据库:From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:

    SQL 复制
    CREATE DATABASE TestDB
  2. 在下一行中,编写一个查询以返回服务器上所有数据库的名称:On the next line, write a query to return the name of all of the databases on your server:

    SQL 复制
    SELECT Name from sys.Databases
  3. 前两个命令没有立即执行。The previous two commands were not executed immediately. 必须在新行中键入 GO 才能执行以前的命令:You must type GO on a new line to execute the previous commands:

    SQL 复制
    GO

提示

若要详细了解如何编写 Transact-SQL 语句和查询,请参阅教程:编写 Transact-SQL 语句。To learn more about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements.

插入数据Insert data

接下来创建一个新表 Inventory,然后插入两个新行。Next create a new table, Inventory, and insert two new rows.

  1. 在 sqlcmd  命令提示符中,将上下文切换到新的 TestDB 数据库:From the sqlcmd command prompt, switch context to the new TestDB database:

    SQL 复制
    USE TestDB
  2. 创建名为 Inventory 的新表:Create new table named Inventory:

    SQL 复制
    CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
  3. 将数据插入新表:Insert data into the new table:

    SQL 复制
    INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
  4. 要执行上述命令的类型 GO:Type GO to execute the previous commands:

    SQL 复制
    GO

选择数据Select data

现在,运行查询以从 Inventory 表返回数据。Now, run a query to return data from the Inventory table.

  1. 通过 sqlcmd  命令提示符输入查询,以返回 Inventory 表中数量大于 152 的行:From the sqlcmd command prompt, enter a query that returns rows from the Inventory table where the quantity is greater than 152:

    SQL 复制
    SELECT * FROM Inventory WHERE quantity > 152;
  2. 执行命令:Execute the command:

    SQL 复制
    GO

退出 sqlcmd 命令提示符Exit the sqlcmd command prompt

要结束 sqlcmd  会话,请键入 QUIT:To end your sqlcmd session, type QUIT:

SQL 复制
QUIT

性能最佳做法Performance best practices

在 Linux 上安装 SQL Server 后,请查看配置 Linux 和 SQL Server 以提高生产性能的最佳做法。After installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. 有关详细信息,请参阅 Linux 上的 SQL Server 的性能最佳做法和配置指南。For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.

跨平台数据工具Cross-platform data tools

除“sqlcmd”以外,还可以使用以下跨平台工具来管理 SQL Server  :In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server:

   
Azure Data StudioAzure Data Studio 跨平台 GUI 数据库管理实用程序。A cross-platform GUI database management utility.
Visual Studio CodeVisual Studio Code 一种跨平台 GUI 代码编辑器,它使用 mssql 扩展运行 Transact-SQL 语句。A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension.
PowerShell CorePowerShell Core 基于 cmdlet 的跨平台自动化和配置工具。A cross-platform automation and configuration tool based on cmdlets.
mssql-climssql-cli 用于运行 Transact-SQL 命令的跨平台命令行接口。A cross-platform command-line interface for running Transact-SQL commands.

从 Windows 连接Connecting from Windows

Windows 上的 SQL Server 工具连接到 Linux 上的 SQL Server 实例,操作方式与连接到任何远程 SQL Server 实例一样。SQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance.

如果有一台可以连接到 Linux 计算机的 Windows 计算机,请从运行 sqlcmd  的 Windows 命令提示符尝试执行本主题中的相同步骤。If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. 仅验证所使用的是目标 Linux 计算机名称或 IP 地址,而非 localhost,并确保 TCP 端口 1433 已打开。Just verify that you use the target Linux machine name or IP address rather than localhost, and make sure that TCP port 1433 is open. 如果从 Windows 进行连接存在任何问题,请参阅连接故障排除建议。If you have any problems connecting from Windows, see connection troubleshooting recommendations.

有关在 Windows 上运行,但连接到 Linux 上的 SQL Server 的其他工具,请参阅:For other tools that run on Windows but connect to SQL Server on Linux, see:

其他部署方案Other deployment scenarios

有关其他安装方案,请参阅以下资源:For other installation scenarios, see the following resources:

   
升级Upgrade 了解如何升级 Linux 版 SQL Server 的现有安装Learn how to upgrade an existing installation of SQL Server on Linux
卸载Uninstall 在 Linux 上卸载 SQL ServerUninstall SQL Server on Linux
无人参与安装Unattended install 了解如何编写无提示安装脚本Learn how to script the installation without prompts
脱机安装Offline install 了解如何手动下载脱机安装程序包Learn how to manually download the packages for offline installation

提示

有关常见问题的解答,请参阅 Linux 上的 SQL Server 常见问题解答。For answers to frequently asked questions, see the SQL Server on Linux FAQ.

后续步骤Next steps

 

此页面有帮助吗?

是 否
还有其他反馈吗? 还有其他反馈吗?
跳过 提交

谢谢。

 

反馈

发送有关以下对象的反馈

此产品

此页面
也可以直接在 GitHub上提供反馈。
此页面
也可以直接在 GitHub上提供反馈。

Liquid error: Can't find the localized string giveDocumentationFeedback for template Conceptual.

问题标题 发表评论 发表评论

提交反馈
本文档当前无任何反馈。 页面反馈将显示在此处。

debian/ubuntu安装mssql的更多相关文章

  1. Debian/Ubuntu安装SSH-Server(SFTP)

    在Debian/Ubuntu命令行执行: sudo apt-get update sudo apt-get install ssh sudo apt-get install openssh-serve ...

  2. debian/ubuntu安装桌面环境

    apt-get install xorg apt-get install gnome 然后startx ubuntu 安装Gnome桌面 1.安装全部桌面环境,其实Ubuntu系列桌面实际上有几种桌面 ...

  3. Debian/Ubuntu 安装bcm43142无线网卡驱动

    Drivers for Broadcom BCM43142 wireless card of Ubuntu/Debian 64-bit Linux 1.Check the wireless card ...

  4. Debian/Ubuntu安装Oracle客户端TNS

    本文作为新手在Linux上部署Java程序的必经之路的Oracle客户端配置,请高手绕道. 确定服务器版本 首选确定你的Oracle服务器版本,以便下载相应的客户端.查看的sql如下: select ...

  5. Debian/Ubuntu安装WPS (转)

    卸载libreoffice sudo apt-get remove --purge libreoffice* 官网下载WPShttp://wps-community.org/downloads?vl= ...

  6. ubuntu 安装Elasticsearch5.0(Debian包)

    通过Debian包安装Elasticsearch Elasticsearch的Debian包可以从downloaded from our website或APT repository 它可以用于在任何 ...

  7. 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境

    CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...

  8. Debian/Ubuntu/CentOS VPS安装Net-Speeder并优化

    安装过程: CentOS安装 wget --no-check-certificate https://gist.github.com/LazyZhu/dc3f2f84c336a08fd6a5/raw/ ...

  9. Debian/Ubuntu手动编译安装MongoDB C++11驱动及驱动测试

    本文章仅限cnblogs网站内转载!请某网站自觉,遵纪守法,尊重原创! 系统环境情况: 最小化.无桌面环境 新安装的Debian 8 Server 版本操作系统虚拟机一台 手动编译安装MongoDB ...

随机推荐

  1. history路由模式下的nginx配置

    路由模式 众所周知,浏览器下的单页面应用的路由模式有下面两种: hash 模式和 history 模式.hash 模式通用性好,而且不依赖服务器的配置,省心省力,但是缺点是不够优雅.相比于 hash ...

  2. AtCoder Grand Contest 014

    AtCoder Grand Contest 014 A - Cookie Exchanges 有三个人,分别有\(A,B,C\)块饼干,每次每个人都会把自己的饼干分成相等的两份然后给其他两个人.当其中 ...

  3. 【LeetCode】145. Binary Tree Postorder Traversal

    Difficulty: Hard  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/binary-tree-pos ...

  4. C# ??(两个问号)的表达式使用详解

    今天有人问我C#中两个问号是什么意思,怎么使用,于是乎有了这篇随笔 有时候我们需要判断某个对象是否为null,一般的做法是 if(x=null){....} 若想让自己的代码更简洁,可以这样写: st ...

  5. VS报错,Metadata file 'xxx.dll' could not be found

    错误提示“Metadata file 'xxx.dll' could not be found”步骤如下:1.右键单击解决方案,然后单击“属性”.2.单击左侧的配置.3.确保选中了它找不到的项目的“生 ...

  6. Lucene PriorityQueue & JDK PriorityQueue

    麻蛋,原来是最小堆呀!  数据结构不熟害死人呀! 看来待复习复习数据结构了 在lucene源码中对多个段合并的时候,会先将多个段放到一个PriorityQueue中,不要被这个名字迷惑,这个Prior ...

  7. Linux 下的 mysql 自动备份

    Linux 下实现自动备份,主要就是编写好执行备份的 shell script( *.sh )文件,设好权限(可读,可执行).然后利用 Linux 定时任务 crontab 来执行备份脚本就可以了.以 ...

  8. 如何从ubuntu或PC传递文件到板子,ubuntu如何上网?

    3.3 如何从ubuntu或PC传递文件到板子,ubuntu如何上网? 答:以下将分别介绍如何在ubuntu和windows下如何传递文件. ubuntu如何配置上网?ubuntu 上网:打开Orac ...

  9. 资深P7架构师详解淘宝服务端高并发分布式架构演进之路

    1. 概述 本文以淘宝作为例子,介绍从一百个并发到千万级并发情况下服务端的架构的演进过程,同时列举出每个演进阶段会遇到的相关技术,让大家对架构的演进有一个整体的认知,文章最后汇总了一些架构设计的原则. ...

  10. PAT 乙级 1032.挖掘机技术哪家强 C++/Java

    题目来源 为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入格式: 输入在第 1 行给出不超过 1 的正整数 N,即参赛人数.随后 ...