win10,docker安装sqlServer2017,并导入备份数据bak
作者:互联网
一、docker安装sqlServer2017
-
拉取镜像
docker pull mcr.microsoft.com/mssql/server:2017-latest
-
启动
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=wade@123" -p 1433:1433 -v D:/database/data:/var/opt/mssql/data --name sqlserver -d mcr.microsoft.com/mssql/server:2017-latest
*密码设置不能太简单,不然启动失败
*挂载目录:D:/database/data
二、导入备份数据
-
将数据上传至容器
docker cp 备份文件路径 sqlserver:/usr/local
-
进入容器
docker exec -it sqlserver bash
-
输入对应账号密码进入
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "wade@123"
-
查询文件的逻辑名
RESTORE FILELISTONLY FROM DISK = '/usr/local/备份文件.bak'
-
结果(LogicalName):
TeamUPDB_INSTALL_1 TeamUPDB_INSTALL_1_log
-
-
使用RESTORE DATABASE命令还原数据库
RESTORE DATABASE mytest
FROM DISK = '/usr/local/OA2007DB_NEW.bak'
WITH
MOVE 'TeamUPDB_INSTALL_1' TO '/var/opt/mssql/data/mytest.mdf',
MOVE 'TeamUPDB_INSTALL_1_log' TO '/var/opt/mssql/data/mytest.ldf',
NOUNLOAD, REPLACE
GO
标签:opt,TeamUPDB,sqlServer2017,INSTALL,win10,docker,data,mssql 来源: https://blog.csdn.net/Z_WADE/article/details/119354113