Installing MSSQL-CLI on macOS

MSSQL-CLI or Microsoft SQL Server CLI is an open source, cross-platform, interactive and syntax highlighting command line query tool for SQL Server. It is an enhanced alternative to SQLCMD. Here we will see how to install MSSQL-CLI on macOS.

Requirements

For installing MSSQL-CLI on macOS, you need:

  • macOS 10.12 (Sierra) or higher.
  • Python 2.7.

Installation

For this demonstration, I’m using macOS High Sierra, MSSQL-CLI 0.15.0.

Installing & Upgrading PIP

MacOS comes with Python pre-installed. Usually the pre-installed Python will be of version 2.7. You can check the installed Python version by launching terminal and executing the command:

python --version

If the version is 2.7, then you need to install and upgrade PIP (Pythons package management system). Follow these steps to do so. If you already have Python 3.6 or higher, ignore this PIP installation and upgrade steps and jump to the MSSQL-CLI installation steps below.

  1. To start with install PIP (Pythons package management system). Open terminal and execute the commend:
    sudo easy_install pip
    
    MSSQL-CLI on macOS Install PIP

  2. If you notice, the easy_install command downloaded and installed pip and its dependencies.
  3. Now, upgrade the pip by executing the command:
    sudo pip install --upgrade pip
    

Installing MSSQL-CLI

After installing and upgrading PIP, you can install MSSQL-CLI using PIP.

  1. In the terminal window, type in the below command and enter.
    sudo pip install mssql-cli --ignore-installed six
    
    MSSQL-CLI on macOS Installation

  2. Now, to see if mssql-cli is working, try launching it with the help argument:
    mssql-cli -h
    
    MSSQL-CLI on macOS

  3. The interactive SQL command line tool is ready for using.

Next Step


2 thoughts on “Installing MSSQL-CLI on macOS”

  1. Hi I installed mssql-cli on mac

    Successfully installed applicationinsights-0.11.9 argparse-1.4.0 click-7.0 configobj-5.0.6 enum34-1.1.10 future-0.18.2 mssql-cli-1.0.0 prompt-toolkit-2.0.10 six-1.14.0 sqlparse-0.2.4 wheel-0.34.2
    bash-3.2$ mssql-cli

    but getting the following message.

    bash: mssql-cli: command not found

    any idea?

    Reply

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.