11

I am very new to SQL and database servers. I have recently been using SQL Server Express and accessing my database using SQL Server Management Studio on Windows. I am now trying to achieve a similar setup on a Linux machine.

I would like to create a local SQL Server instance on the machine, and then use SQLectron as a GUI client for querying my database. I am using Manjaro Linux and so install my packages from the AUR.

So far I have installed mssql-server, mssql-tools and sqlectron-gui. I have run the sudo /opt/mssql/bin/mssql-conf setup command in order to (I believe) set up a local server. After doing so, running the command systemctl status mssql-server returns this:

[kev@XPS-Manjaro ~]$ systemctl status mssql-server
くろまる mssql-server.service - Microsoft SQL Server Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2017年08月23日 13:43:49 IST; 2h 42min ago
 Docs: https://learn.microsoft.com/en-us/sql/linux
Main PID: 9130 (sqlservr)
 Tasks: 165
CGroup: /system.slice/mssql-server.service
 ├─9130 /opt/mssql/bin/sqlservr
 └─9144 /opt/mssql/bin/sqlservr
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [145B blob data]
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [66B blob data]
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [96B blob data]
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [100B blob data]
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [71B blob data]
Aug 23 13:43:52 XPS-Manjaro sqlservr[9130]: [124B blob data]
Aug 23 13:49:03 XPS-Manjaro sqlservr[9130]: [156B blob data]
Aug 23 13:49:03 XPS-Manjaro sqlservr[9130]: [194B blob data]
Aug 23 13:52:31 XPS-Manjaro sqlservr[9130]: [74B blob data]
Aug 23 13:52:31 XPS-Manjaro sqlservr[9130]: [199B blob data]

I am now attempting to create a local connection to my server through SQLectron on the following screen:

enter image description here

As I have very little experience with SQL Servers, I am completely lost with where to get all of these credentials to connect to my local server. The only one I know of is the password which I set in the sudo /opt/mssql/bin/mssql-conf setup command.

How do I find the server name, host address (127.0.0.1?), port, domain, Unix socket path and username?

Hannah Vernon
71.1k22 gold badges178 silver badges324 bronze badges
asked Aug 23, 2017 at 14:09
0

1 Answer 1

7

If you are running the GUI on the same machine as the mssql-server service, then you can use localhost for the address (127.0.0.1). If you are running the GUI from a different workstation, you'll need the IPv4 address of the machine where the mssql-server service is running. You can obtain that by running ifconfig from a Linux terminal prompt. Sample output from ifconfig:

eth0: flags=4163 mtu 1500
 ether 00:15:5d:89:45:01 txqueuelen 1000 (Ethernet)
 RX packets 423 bytes 137827 (134.5 KiB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 0 bytes 0 (0.0 B)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163 mtu 1500
 inet 192.168.200.11 netmask 255.255.255.0 broadcast 192.168.200.255
 inet6 fe80::2f70:9d15:8e7d:16cb prefixlen 64 scopeid 0x20
 ether 00:15:5d:89:45:04 txqueuelen 1000 (Ethernet)
 RX packets 20138 bytes 2006000 (1.9 MiB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 19756 bytes 30125657 (28.7 MiB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
 inet 127.0.0.1 netmask 255.0.0.0
 inet6 ::1 prefixlen 128 scopeid 0x10
 loop txqueuelen 1 (Local Loopback)
 RX packets 3239 bytes 361340 (352.8 KiB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 3239 bytes 361340 (352.8 KiB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

In the output above, the bit that is important is the "inet" address, which in my case is 192.168.200.11.

The default port for SQL Server is 1433 - unless you chose a different port in mssql-conf use that port number. Ensure the firewall on the Linux box is allowing outside connections via 1433, if you intend to connect to SQL Server via the network.

Use sa as the login, and the password you specified during SQL Server setup via the sudo /opt/mssql/bin/mssql-conf setup command.

I would leave the domain and unix socket path blank.

Once you have connected to the instance, you may want to configure a non-sa account. Do that with the CREATE LOGIN statement.

Just an FYI, you can use SQL Server Management Studio to connect to SQL Server on Linux, if that's your desire. Alternately, you can download Microsoft's native GUI client for Linux (and Windows & Mac), Azure Data Studio, here.

answered Aug 23, 2017 at 15:30
3
  • One last follow on: If I now wanted to access my database from within a Python script, would I just need to configure my non-sa account as you mentioned, and then install some driver? I used the ODBC Driver when working on Windows. In my Pyton script on Windows, I got my server name for the connection engine from SSMS which was in the form of CPX-9GL9XXXXXXX\SQLEXPRESS. How can I find this equivalent server name without having access to SSMS? Commented Aug 23, 2017 at 15:58
  • SQL Server Browser is used to locate SQL Server instances without knowing the port number in advance... so for CPX-9GL9XXXXXXX\SQLEXPRESS -> SQLEXPRESS is the instance name, which would be translated by SQL Server Browser service into a port number. Unfortunately, SQL Server Browser is not yet supported on Linux, so you need to know the port number, which is 1433 by default. Commented Aug 23, 2017 at 16:10
  • I'm not certain what driver you'd use, but the mssql-tools package includes an odbc driver as far as I know. Commented Aug 23, 2017 at 20:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.