当前位置:   article > 正文

在Mac中搭建SQL Server_mac 安装sqlserver 并导入bak文件

mac 安装sqlserver 并导入bak文件

前言

本文将介绍如何在Mac电脑上搭建SQL Server,主要涉及以下应用软件:

  1. Docker
  2. Azure Data Studio
  3. Navicat Premium

其中1可以理解为Adapter;2,3可以连接到本地mssql,并通过GUI运行sql脚本。

Docker安装与配置

  1. 下载链接:Download Docker Desktop for Mac
    • 这里有两个选项:默认选第一个
      • Mac with Intel chip
      • Mac with Apple chip
  2. 安装完Docker并打开 -> 点击Preferences -> Resources -> Advanced后,按下图推荐配置Memory: 4GB在这里插入图片描述
  3. 使用Terminal创建Container
    • Pull official images for Microsoft SQL Server on Linux for Docker Engine,参照:Microsoft SQL Server
      # Format
      docker pull mcr.microsoft.com/mssql/server:<image_tag>
      # Example:
      docker pull mcr.microsoft.com/mssql/server:2019-latest
      
      • 1
      • 2
      • 3
      • 4
    • 创建Container
      # Format
      docker run -d --name <container_name> -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<strong_pwd>’ -e 'MSSQL_PID=<edition>’ -p 1433:1433 -d mcr.microsoft.com/mssql/server:<image_tag>
      # Example
      docker run -d --name jll_dev -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=@dmin!234' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
      
      • 1
      • 2
      • 3
      • 4
  4. 打开Docker Dashboard即可看到正在运行的Container在这里插入图片描述
    Note:如果图示标记状态总是自动从running -> exited,一个可能的原因是密码复杂度不够不合规

    Specify your own strong password that is at least 8 characters and meets the SQL Server password requirements. Required setting for the SQL Server image.

Azure Data Studio安装

  1. 下载链接:Download and install Azure Data Studio
  2. 安装后即可新建本地连接,如下图:
    在这里插入图片描述
    同样的,我们也可以使用Navicat Premium来连接本地sql server。
    在这里插入图片描述

导入bak文件

当我们把bak文件存在Mac的某个目录下后,可以使用命令行将文件转存到container的文件系统中,然后使用Azure Data Studio的Restore操作来恢复数据。

  1. 打开Terminal按如下步骤操作:
    过程记录:
    cd enter -> 回到根目录
    # Format: 
    sudo docker exec -it <container_name> mkdir var/opt/mssql/backup
    # Example: 在容器的文件系统中创建一个backup文件夹
    sudo docker exec -it jll_dev mkdir var/opt/mssql/backup
    
    • 1
    • 2
    • 3
    • 4
    # 假如备份文件存在该目录下
    cd /Users/xuyan/项目/公司/xxx/JLL/db
    # 列举文件夹下的文件
    ls
    # 复制bak文件文件名,如:bak_file='Data_Backup_20210716.bak'
    # Format: 
    sudo docker cp <bak_file> <container_name>:var/opt/mssql/backup
    # Example: 将Mac本地的bak文件转存到Docker容器的文件系统目录下
    sudo docker cp Data_Backup_20210716.bak jll_dev:var/opt/mssql/backup
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    过程截图:
    在这里插入图片描述
  2. 前往Azure Data Studio从备份文件恢复数据
    在这里插入图片描述在这里插入图片描述

其他

#1. 免费的SFTP文件传输工具:Cyberduck

1.1 简介
Cyberduck is a free FTP client designed for both Windows and Mac. In fact, unlike most cross platform FTP client solutions, Cyberduck integrates seamlessly with your native Mac environment, making it one of the best Mac FTP clients available. It even supports Mac features such as storing login credentials in keychain and locating files in the Finder.

1.2 优点

  • Simple interface for beginners
  • Allows for remote file editing
  • Works with several external code editors
  • Open files and edit both text and binary files with a click of a button
  • Wide range of protocols including FTP, SFTP, and WebDAV
  • Advanced SSH functionality and bookmarking capability
  • Client side encryption
  • Supports API connections with cloud drives like Google Drive and Dropbox
  • Multiple languages

1.3 缺点

  • Tends to run slower than other FTP clients
  • No portable version
  • Download from anywhere other than official website can come with adware

Although Cyberduck works for both Windows and Mac users, this option is touted as one of the best for Mac users, as there are better Windows options available. That said, Cyberduck is an inexpensive solution that will get the job done whether you use Windows or Mac.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/680242
推荐阅读
相关标签
  

闽ICP备14008679号