> For the complete documentation index, see [llms.txt](https://enterprise-ua.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-ua.hideez.com/korporativnii-server-hideez/rozgortannya/vstanovlennya-bazi-danikh/microsoft-sql-server-na-linux.md).

# Microsoft SQL Server на Linux

### 1. Встановлення

Деталізована установка Microsoft SQL Server описана [тут](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15). Ми просто повторюємо кроки офіційної  документації.

*Centos 7:*

```
# Імпортуйте ключі GPG загальнодоступного сховища
$ 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

# Завантажте файл конфігурації сховища Microsoft Red Hat.
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

# Налаштуйте mssql за допомогою Express (безкоштовного) параметра номер 3
$ sudo /opt/mssql/bin/mssql-conf setup

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

*Ubuntu 18.04 :*

```
# Імпортуйте ключі GPG загальнодоступного сховища 
$ 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

# Налаштуйте mssql за допомогою Express (безкоштовного) параметра номер 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:*

```
# Імпортуйте ключі GPG загальнодоступного сховища 
$ 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

# Налаштуйте mssql за допомогою Express (безкоштовного) параметра номер 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  
```

Щоб зробити sqlcmd/bcp доступним із оболонки bash для інтерактивних сеансів/сеансів без входу, змініть PATH у файлі \~/.bashrc за допомогою такої команди:

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

*Ubuntu 22.04:*

```
На жаль, наразі корпорація Майкрософт офіційно не підтримує цю ОС.
Ми відстежуємо підтримувані платформи за адресою https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver15#supportedplatforms
```

## 2. Створення користувача та бази даних SQL Server

2.1. Запустіть sqlcmd та введіть ваш пароль root (замініть `<YourSAPassword>` на ваш справжній пароль)

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

2.2. Наступні строки створюють БД `hesdb`, користувача з іменем `hesuser` та паролем `<user_password>`. Замініть `<user_password>` на сильний пароль, інакше Ви отримаєте помилку валідації пароля.

```
> 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
```

Щоб вийти з консолі Transact-SQL натисніть 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:

```
GET https://enterprise-ua.hideez.com/korporativnii-server-hideez/rozgortannya/vstanovlennya-bazi-danikh/microsoft-sql-server-na-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
