为了账号安全,请及时绑定邮箱和手机立即绑定

如何在Linux/MacOS系统上安装Microsoft SQL Server

标签:
SQL Server

转载来源:https://hub.docker.com/_/mssql-server-linux

 

如何在Linux/MacOS系统上安装Microsoft SQL Server

 

快速安装

# 首先在Linux上安装docker,然后执行以下命令,然后用vscode上的MSSQL插件登录MSSQL服务器
$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express' -p 1433:1433 -d microsoft/mssql-server-linux:latest

https://img1.sycdn.imooc.com//5c1a231a0001d66312800800.jpg

 

We're moving!

We are moving to mcr.microsoft.com where you can pull SQL Server 2017 on Linux containers as well as SQL Server 2019 preview containers. SQL Server 2019 preview containers will only be available on mcr.microsoft.com. Overtime we will only publish to mcr.microsoft.com/mssql/server and eventually deprecate microsoft/mssql-server-linux.

Visit our new Docker Hub page at https://hub.docker.com/r/microsoft/mssql-server Learn more about Microsoft Container Registry at https://azure.microsoft.com/en-us/blog/microsoft-syndicates-container-catalog

Supported tags and respective Dockerfile links

Notes: GA = General Availability - when the version is officially available and supported. CU = Cumulative Update - a periodic release that includes bug fixes, security fixes, and occasionally a small feature. CTP = Community Technology Preview - a preview release that precedes the GA of an upcoming new version. GDR = General Distribution Release - a release that contains ONLY security fixes.


License

By passing the value "Y" to the environment variable "ACCEPT_EULA", you are expressing that you have a valid and existing license for the edition and version of SQL Server that you intend to use. You also agree that your use of SQL Server software running in a Docker container image will be governed by the terms of your SQL Server license.

To specify the edition, use the MSSQL_PID environment variable. Details can be found in the "Environment Variables" section below.

SQL Server Developer edition lets developers build any kind of application on top of SQL Server. It includes all the functionality of Enterprise edition, but is licensed for use as a development and test system, not as a production server. SQL Server Developer Edition cannot be used in a production environment. The SQL Server 2017 Developer Edition license terms are located here.


Known Issues

  • Mounting a volume does not work on Docker for Mac

View other issues on the mssql-docker GitHub Project.

Documentation

Microsoft SQL Server on Linux for Docker Engine. Learn more about the latest release of SQL Server on Linux here.


Requirements

  • This image requires Docker Engine 1.8+ in any of their supported platforms.

  • At least 2GB of RAM (3.25 GB prior to 2017-CU2). Make sure to assign enough memory to the Docker VM if you're running on Docker for Mac or Windows.

  • Requires the following environment flags

    • ACCEPT_EULA=Y

    • SA_PASSWORD=<your_strong_password>

    • MSSQL_PID=<your_product_id | edition_name> (default: Developer)

  • A strong system administrator (SA) password: At least 8 characters including uppercase, lowercase letters, base-10 digits and/or non-alphanumeric symbols.


How to use this image

Start a mssql-server instance using the CU8 release

IMPORTANT NOTE: If you are using PowerShell on Windows to run these commands use double quotes instead of single quotes.

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux:2017-CU8

Start a mssql-server instance using the latest update for SQL Server 2017

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux:latest

Start a mssql-server instance running as the SQL Express edition

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express' -p 1433:1433 -d microsoft/mssql-server-linux:latest

Connect to Microsoft SQL Server

You can connect to the SQL Server using the sqlcmd tool inside of the container by using the following command on the host:

docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>

You can also use the tools in an entrypoint.sh script to do things like create databases or logins, attach databases, import data, or other setup tasks. See this example of using an entrypoint.sh script to create a database and schema and bcp in some data.

You can connect to the SQL Server instance in the container from outside the container by using various command line and GUI tools on the host or remote computers. See the Connect and Query topic in the SQL Server on Linux documentation.

Environment Variables

ACCEPT_EULA confirms your acceptance of the End-User Licensing Agreement.

SA_PASSWORD is the database system administrator (userid = 'sa') password used to connect to SQL Server once the container is running. Important note: This password needs to include at least 8 characters of at least three of these four categories: uppercase letters, lowercase letters, numbers and non-alphanumeric symbols.

MSSQL_PID is the Product ID (PID) or Edition that the container will run with. Acceptable values:

  • Developer : This will run the container using the Developer Edition (this is the default if no MSSQL_PID environment variable is supplied)

  • Express : This will run the container using the Express Edition

  • Standard : This will run the container using the Standard Edition

  • Enterprise : This will run the container using the Enterprise Edition

  • EnterpriseCore : This will run the container using the Enterprise Edition Core

  • <valid product id> : This will run the container with the edition that is associated with the PID

For a complete list of environment variables that can be used, refer to the documentation here.


User Feedback

  • For issues with or questions about this image, please contact us through a GitHub issue.


Additional Microsoft SQL Server Docker Images


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消