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.
For installing MSSQL-CLI on macOS, you need:
- macOS 10.12 (Sierra) or higher.
- Python 2.7.
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:
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.
- To start with install PIP (Pythons package management system). Open terminal and execute the commend:
sudo easy_install pip
- If you notice, the easy_install command downloaded and installed pip and its dependencies.
- Now, upgrade the pip by executing the command:
sudo pip install --upgrade pip
After installing and upgrading PIP, you can install MSSQL-CLI using PIP.
- In the terminal window, type in the below command and enter.
sudo pip install mssql-cli --ignore-installed six
- Now, to see if mssql-cli is working, try launching it with the help argument:
- The interactive SQL command line tool is ready for using.
- Read more about using and running SQL queries in MSSQL-CLI.
- Read about other major SQL Server management and development tools.