Working with Sql Server on Archlinux

Note
This article was last updated on 31-10-2022, the content may be out of date.

Just a few simple step to make your linux works with mssql

In this post, I will covers how I installed Microsoft SQL Server on Arch Linux. I do this using AUR repositories.

mssql-server – this is for the main MS SQL Server installation msodbcsql – this is for connecting to MS SQL Server mssql-tools – these are the command line tools for interacting with MS SQL Server

1
yay -S mssql-server msodbcsql mssql-tools

After all three of the packages have been installed. The mssql-server service should also now be running and enabled to start automatically. You can check by running:

1
sudo systemctl status mssql-server.service

If it’s showing as “inactive (dead)” you can easily start the service and enable it to run automatically:

1
2
sudo systemctl enable mssql-server.service
sudo systemctl start mssql-server.service

Use simple command to setup mssql

1
sudo /opt/mssql/bin/mssql-conf setup

Feel free to choose any edition which depend on your purpose, the output may look like

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
  7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
  8) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-8): 

Click the arrow to see the content !!

Make sure you accept the license terms, type Yes

Then enter SQL Server system administartor password

1
sqlcmd -S localhost -U sa

If you get error : Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate]

When SQL Server gets installed it is configured with a self-signed X.509 certificate. If you want to use encrypted connections (with Encrypt=yes; in the connection string, which is the default now) you’ll either need to 1) get the X.509 certificate’s public key from the server and add it to your trusted certificates store on the client or 2) use the TrustServerCertificate=yes; setting in your connection string

Or simply use command

1
sqlcmd -S <server> -U <username> -P <password> -C

Ex:

1
sqlcmd -S localhost -U sa -P 'YourPassword' -C

You can install vscode and some extentions to work with mssql easier

Open vscode, Ctrl + P and install:

ext install ms-mssql.mssql

Click the icon of mssql extentions which showing on Activity Bar and Add Connection

  • Hostname: localhost

  • Database name: enter to skip

  • Authentication Type: SQL Login

  • User name : sa

  • Password: The password which you created before

  • Save password: Your choice

  • Enter display name: Your choice

Then just create a simple query and test it ^^

If you get trouble, feel free to contact me.