Question

Whenever I run sqlcmd I get "command not found"

sqlcmd -S localhost -U SA -P '<YourPassword>'
sqlcmd: command not found

How can I resolve that?

Was it helpful?

Solution

There are two methods of resolving this.

  1. Insane Method for those that do not how to use Linux, advocated in the manual, add the directory to the environmental variable PATH.
  2. Sane Method that follows the Linux FHS, symlink the executable to the directory already in the path.

Insane Method

HINT: Do NOT follow the advice of the tutorial You can find the tutoral's (reproduced here)**. The tutorial states the following.

Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

This works, but it's subpar.

Sane Method

Follow the Filesystem Hierarchy Standard

sudo ln -s /opt/mssql-tools/bin/* /usr/local/bin/

This should just be in their postinst script, but you know... Microsoft etc.,

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top