Connecting to SQL Azure with SQL Management Studio - DZone Database

Default port for MS SQL Server

Port / March 29, 2015

Configuration of SQL Server on Linux with mssql-conf

As per Microsoft documentation, mssql-conf is a configuration script that installs with SQL Server vNext CTP 1.2 for Red Hat Enterprise Linux, SUSE Linux Enterprise Server, and Ubuntu. We can use this utility to set the following parameters:

  • TCP port: Change the port where SQL Server will listen for connections.
  • Default data directory: Change the directory for new SQL Server database data files (.mdf).
  • Default log directory: Changes the directory for new SQL Server database log (.ldf) files are created.
  • Default dump directory: Change the directory where SQL Server will deposit memory dumps and other troubleshooting files by default.
  • Default backup directory: Change the directory where SQL Server will send backup files by default.
  • Set traceflags: Set the trace flags that the service is going to use.
  • Set collation: Set a new collation for SQL Server on Linux.

Change default SQL Server TCP Port

Now suppose we want to change the default TCP Port of SQL Server from 1433 to 5500, follow the below steps.

1. Run the mssql-conf script as root with the "set" command for "tcpport". In the below query I specified tcpport 5500, but you can use whatever available port you would like.

sudo /opt/mssql/bin/mssql-conf set tcpport 5500

2. Restart the SQL Server service.

As we can see above, after we apply new tcpport, it gives notification to restart SQL Server service.

sudo systemctl restart mssql-server

3.We may need to run the below commands to open the SQL Server port on the firewall on the Linux server.

sudo firewall-cmd -zone=public -add-port=5500/tcp -permanent sudo firewall-cmd -reload

4. Check the SQL Server service to the verify port has changed.

We can see now the SQL service is running on port 5500.

Next Steps
  • In another tip we will explore how to change the default location of data files and log files.
About the author
Rajendra is a Consultant DBA with 9+ years of extensive experience in database administration including large critical OLAP, OLTP, Reporting and SharePoint databases.