5

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?

8

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.,

  • I would suggest this to Microsoft through connect so eventually this gets corrected. – Max Vernon May 23 '17 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.