Docker中安裝SQLServer,并且導(dǎo)入.mdf和.ldf文件
Docker中安裝SQLServer,并且導(dǎo)入.mdf和.ldf文件
?一、 docker pull mcr.microsoft.com/mssql/server:2017-latest
二、docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=your-password' -p 1433:1433 -v /var/opt/ms-data:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest
注意要映射文件夾 !
docker ps -a?
docker inspect? ?容器id,這里是40cab90ef42b?
三、docker cp 自己Linux中l(wèi)aboratory.mdf路徑 容器id:/var/opt/mssql/data/laboratory.mdf
docker cp 自己Linux中l(wèi)aboratory_log.ldf路徑 容器id:/var/opt/mssql/data/laboratory_log.ldf
docker cp /var/opt/ms-data/Electronic.mdf? ?40cab90ef42b:/var/opt/mssql/data/Electronic.mdf
docker cp /var/opt/ms-data/Electronic_log.ldf? ??40cab90ef42b:/var/opt/mssql/data/Electronic_log.ldf
四、 附加數(shù)據(jù)庫(kù)
?
然后在llinux中查詢,(在navicat中進(jìn)行查詢會(huì)失?。?/p>
EXEC sp_attach_db @dbname = ‘?dāng)?shù)據(jù)庫(kù)名’,
@filename1 = ‘/var/opt/mssql/data/MDF文件’,
@filename2 = ‘/var/opt/mssql/data/ldf文件’

五、使用Navicat連接SQLServer數(shù)據(jù)庫(kù)
打開(kāi)數(shù)據(jù)庫(kù)??Electronic , 導(dǎo)出sql文件