docker安装sqlserver 数据库

57 篇文章 0 订阅
7 篇文章 0 订阅

具备条件:

1.服务器需要大于2G内存。如果不够则可能无法正常启动,查看日志报如下错误:
This program requires a machine with at least 2000 megabytes of memory

2、获取 sqlserver 镜像
$ docker pull mcr.microsoft.com/mssql/server:2017-latest

镜像下载成功后,运行镜像
$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=sa1122.?' -p 1433:1433 -v /opt/data/sqlserver/:/var/opt/mssql/data/ --name sqlserver -d mcr.microsoft.com/mssql/server:2017-latest

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=sa123456' -e 'MSSQL_PID=Developer' -p 1433:1433 -v mssqldata:/var/opt/mssql --name mssql -d microsoft/mssql-server-linux

查看日志

复制代码

2019-03-27 09:25:02.28 spid7s      Converting database 'msdb' from version 862 to the current version 869.
2019-03-27 09:25:02.29 spid7s      Database 'msdb' running the upgrade step from version 862 to version 863.
2019-03-27 09:25:02.30 spid10s     Converting database 'model' from version 862 to the current version 869.
2019-03-27 09:25:02.30 spid10s     Database 'model' running the upgrade step from version 862 to version 863.
2019-03-27 09:25:02.43 spid10s     Database 'model' running the upgrade step from version 863 to version 864.
2019-03-27 09:25:02.43 spid7s      Database 'msdb' running the upgrade step from version 863 to version 864.
2019-03-27 09:25:02.45 spid10s     Database 'model' running the upgrade step from version 864 to version 865.
2019-03-27 09:25:02.46 spid7s      Database 'msdb' running the upgrade step from version 864 to version 865.
2019-03-27 09:25:02.46 spid10s     Database 'model' running the upgrade step from version 865 to version 866.
2019-03-27 09:25:02.47 spid7s      Database 'msdb' running the upgrade step from version 865 to version 866.
2019-03-27 09:25:02.48 spid10s     Database 'model' running the upgrade step from version 866 to version 867.
2019-03-27 09:25:02.49 spid7s      Database 'msdb' running the upgrade step from version 866 to version 867.
2019-03-27 09:25:02.50 spid10s     Database 'model' running the upgrade step from version 867 to version 868.
2019-03-27 09:25:02.51 spid7s      Database 'msdb' running the upgrade step from version 867 to version 868.
2019-03-27 09:25:02.52 spid10s     Database 'model' running the upgrade step from version 868 to version 869.
2019-03-27 09:25:02.52 spid7s      Database 'msdb' running the upgrade step from version 868 to version 869.
2019-03-27 09:25:02.65 spid10s     Polybase feature disabled.
2019-03-27 09:25:02.65 spid10s     Clearing tempdb database.
2019-03-27 09:25:03.07 spid10s     Starting up database 'tempdb'.
2019-03-27 09:25:03.33 spid10s     The tempdb database has 1 data file(s).
2019-03-27 09:25:03.33 spid22s     The Service Broker endpoint is in disabled or stopped state.
2019-03-27 09:25:03.33 spid22s     The Database Mirroring endpoint is in disabled or stopped state.
2019-03-27 09:25:03.35 spid22s     Service Broker manager has started.
2019-03-27 09:25:03.44 spid7s      Recovery is complete. This is an informational message only. No user action is required.
2019-03-27 09:25:03.47 spid24s     The default language (LCID 0) has been set for engine and full-text services.

3、登录 sqlserver 容器(登录容器后创建数据库,具体步骤详见最下面的图)
docker exec -it sqlserver bash

4、连接 sqlserver
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P password
例如:/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P sa1122.?

注意:密码8位复杂字符,否则容器启动不了

5、执行命令
SELECT Name from sys.Databases
go

### 创建数据库
create database mytest COLLATE Chinese_PRC_CI_AS

go


 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值