MS SQL Server#
Connect from Ubuntu#
To connect to an MS SQL Server from the command line on a Linux Ubuntu system, you can use the sqlcmd command-line tool provided by Microsoft. Here's how you can do it
1. Install the Required Tools#
2. Add sqlcmd to PATH#
3. Connect to MS SQL Server#
Bash | |
---|---|
Replace:
with the hostname or IP address of the SQL Server (e.g., localhost, 192.168.1.100, or myserver.database.windows.net). with your SQL Server username. with your SQL Server password.
Example:
Bash | |
---|---|
4. Run SQL Commands#
Once connected, you can run SQL queries. For example:
Use GO to execute the command. Type QUIT to exit the session.
Troubleshooting
-
Ensure the SQL Server is reachable from your Ubuntu machine (e.g., check firewall rules or network connectivity).
-
If using Azure SQL, ensure your IP is allowed in the server's firewall settings.