> For the complete documentation index, see [llms.txt](https://enterprise.hideez.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enterprise.hideez.com/hideez-enterprise-server/deployment/database-installation/microsoft-sql-server-on-linux.md).

# Microsoft SQL Server on Linux

### 1. Installation

Detailed installation of the Microsoft SQL Server is described [here](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15). We are just repeating the steps of the official documentation.

*Centos 7:*

```
# Import the public repository GPG keys 
$ sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
$ sudo yum install -y mssql-server

# Download the Microsoft Red Hat repository configuration file.
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

# Setup mssql use Express (free) option number 3
$ sudo /opt/mssql/bin/mssql-conf setup

$ sudo yum install -y mssql-tools unixODBC-devel
```

*Ubuntu 18.04 :*

```
# Import the public repository GPG keys 
$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
$ sudo apt-get update
$ sudo apt-get install -y mssql-server

# Setup mssql use Express (free) option number 3
$ sudo /opt/mssql/bin/mssql-conf setup
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update 
$ sudo apt-get install mssql-tools unixodbc-dev -y  
```

*Ubuntu 20.04:*

```
# Import the public repository GPG keys 
$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"
$ sudo apt-get update
$ sudo apt-get install -y mssql-server

# Setup mssql use Express (free) option number 3
$ sudo /opt/mssql/bin/mssql-conf setup
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list |  sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update 
$ sudo apt-get install mssql-tools unixodbc-dev -y  
```

To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the \~/.bashrc file with the following command:

```
$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
$ source ~/.bashrc
```

*Ubuntu 22.04:*

```
Unfortunately, Microsoft does not officially support this OS at the moment. 
We track supported platforms at https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15#supportedplatforms
```

## 2. Creating SQL Server User and Database

2.1. Run sqlcmd and enter your root password (change `<YourSAPassword>` with your real password)

```
sqlcmd -S localhost -U SA -P '<YourSAPassword>'
```

2.2. The following lines create a database `hesdb`, the user with name `hesuser` and password `<user_password>`. Сhange `<user_password>` to a strong password, otherwise you may get a password validator error.

```
> CREATE LOGIN [hesuser] WITH PASSWORD = '<user_password>';
> GO
> CREATE DATABASE hesdb;
> GO
> USE hesdb; 
> GO
> CREATE USER [hesuser] from login [hesuser];
> GO
> GRANT CONTROL ON DATABASE::hesdb  TO [hesuser];
> GO
```

To exit from the Transact-SQL console, press Ctrl+C.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://enterprise.hideez.com/hideez-enterprise-server/deployment/database-installation/microsoft-sql-server-on-linux.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
