On April 20, 2017 10:00-11:00 AM Pacific Time (UTC-7) Microsoft will host a Security in SQL Server on Linux Microsoft Engineering Town Hall
Here is what will be covered
Learn about recent developments and get answers to your questions at twice-monthly virtual town halls, where Microsoft connects you with the team behind SQL Server on Linux. Each session will begin with a new topic, but all questions about SQL on Linux are welcome. At this event, you’ll:
Engage with—and ask questions of—the SQL Server on Linux engineering team.
Learn about how SQL Server in Linux supports the same enterprise-grade security capabilities that customers rely on with SQL Server on Windows. Get an overview of how to secure SQL Server on Linux, with demos of popular scenarios.
Today, I decided to see how I can change the port SQL Server is listening on
To see what port SQL Server is listening on, you can use the netstat command, here is what the output looks like when I run netstat -tulpn | grep sqlservr
I used grep to limit the output to lines that contain sqlservr only
Next, to change the port that SQL Server is listening on to 3000, I ran the following command
sudo /opt/mssql/bin/mssql-conf set tcpport 3000
I restarted SQL Server bu running the command systemctl restart mssql-server
Then I ran netstat -tulpn | grep sqlservr again and as you can see the output now has 3000 as the port number
Now I tried using sqlcmd, I ran the following sqlcmd -S localhost -U SA
I got an timeout error
Finally I ran the sqlcmd command again but I added port number 3000, like this sqlcmd -S localhost,3000 -U SA
As you can see, this worked and I could connect to SQL Server listening on port 3000 when supplying that to the sqlcmd command
How do we reset SQL Server back to the default port?
To reset SQL Server back to use the default port, run the command below
/opt/mssql/bin/mssql-conf unset tcpport
Here is a screenshot of running netstat, resetting the port, restarting SQL Server and running netstat again
You want to learn a little more?
We used tulpn as options in our netstat command. So what do all these options do?
[-t]
tcp
[-u]
udp
[-l]
Show only listening sockets
[-p]
Show the PID (process identifier) and name of the program to which each socket belongs.
[-n]
Show numerical addresses instead of trying to determine symbolic host, port or user names.
On a Linux system to get help for a command, use man, this will bring up the user manual for that command
So if you run man netstat, you will see the following (I only pasted 1 page here, there are more)
I decided to play around with installing SQL Server vNext on Linux today. I decided to pick the Ubuntu distribution. I created a VM in VirtualBox and then installed Ubuntu 16.04. After that was done, it was time to install SQL Server.
All this stuff on this page runs on Linux, there are no windows components, if you have just a Linux desktop/server, you are all set
I finally installed SQL Server on Linux, while I was messing around with some queries, I noticed the following command fails with an error
exec xp_readerrorlog
The error is
Started executing query at Line 1
Msg 22004, Level 16, State 1, Line 0 Failed to open loopback connection. Please see event log for more information.
Msg 22004, Level 16, State 1, Line 0 Error log location not found.
Total execution time: 00:01:01.34
So how do you then look at the log on Linux? I don't have SSMS installed on the host machine where the Linux Virtual Machine lives. SQLCMD gives the same error. I don't know if it even works from SSMS from a windows box.
Edit: so it looks like it works from SSMS
@DenisGobo SSMS reading SQL logs works. Also quick tested xp_readerrorlog 0, 1 - works fine as well.