[comment]: # translation:outdated

[comment]: # ({7af1bbaa-7af1bbaa})
# 1 Створення бази даних

[comment]: # ({/7af1bbaa-7af1bbaa})

[comment]: # ({29b37d78-fab90562})
#### Огляд

Базу даних Zabbix необхідно створити під час встановлення Zabbix-сервера або проксі.

Цей розділ містить інструкції щодо створення бази даних Zabbix. Для кожної підтримуваної бази даних доступний окремий набір інструкцій.

UTF-8 є єдиним кодуванням, яке підтримує Zabbix. Відомо, що він працює без будь-яких недоліків безпеки. Користувачі повинні знати, що існують відомі проблеми безпеки, якщо використовувати деякі з інших кодувань.

[comment]: # ({/29b37d78-fab90562})

[comment]: # ({2293abd2-fad527fc})
::: noteclassic
Якщо інсталяція здійснюється з [репозиторію Zabbix Git] https://git.zabbix.com/projects/ZBX/repos/zabbix/browse), вам потрібно запустити таку команду, перш ніж переходити до наступних кроків:
<br><br>
`$ make dbschema`
:::

[comment]: # ({/2293abd2-fad527fc})

[comment]: # ({new-1e36e539})
#### MySQL

Character sets utf8 (aka utf8mb3) and utf8mb4 are supported (with
utf8\_bin and utf8mb4\_bin collation respectively) for Zabbix
server/proxy to work properly with MySQL database. It is recommended to
use utf8mb4 for new installations.

    shell> mysql -uroot -p<password>
    mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
    mysql> create user 'zabbix'@'localhost' identified by '<password>';
    mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
    mysql> quit;

::: notewarning
If you are installing from Zabbix **packages**, stop
here and continue with instructions for
[RHEL/CentOS](https://www.zabbix.com/download?zabbix=5.0&os_distribution=red_hat_enterprise_linux&os_version=8&db=mysql)
or
[Debian/Ubuntu](https://www.zabbix.com/download?zabbix=5.0&os_distribution=debian&os_version=10_buster&db=mysql)
to import the data into the database.
:::

If you are installing Zabbix from sources, proceed to import the data
into the database. For a Zabbix proxy database, only `schema.sql` should
be imported (no images.sql nor data.sql):

    shell> cd database/mysql
    shell> mysql -uzabbix -p<password> zabbix < schema.sql
    # stop here if you are creating database for Zabbix proxy
    shell> mysql -uzabbix -p<password> zabbix < images.sql
    shell> mysql -uzabbix -p<password> zabbix < data.sql

[comment]: # ({/new-1e36e539})

[comment]: # ({new-61d6043c})
#### PostgreSQL

You need to have database user with permissions to create database
objects. The following shell command will create user `zabbix`. Specify
password when prompted and repeat password (note, you may first be asked
for `sudo` password):

    shell> sudo -u postgres createuser --pwprompt zabbix

Now we will set up the database `zabbix` (last parameter) with the
previously created user as the owner (`-O zabbix`).

    shell> sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix

::: notewarning
If you are installing from Zabbix **packages**, stop
here and continue with instructions for
[RHEL/CentOS](https://www.zabbix.com/download?zabbix=5.0&os_distribution=red_hat_enterprise_linux&os_version=8&db=postgresql)
or
[Debian/Ubuntu](https://www.zabbix.com/download?zabbix=5.0&os_distribution=debian&os_version=10_buster&db=postgresql)
to import the initial schema and data into the database.
:::

If you are installing Zabbix from sources, proceed to import the initial
schema and data (assuming you are in the root directory of Zabbix
sources). For a Zabbix proxy database, only `schema.sql` should be
imported (no images.sql nor data.sql).

    shell> cd database/postgresql
    shell> cat schema.sql | sudo -u zabbix psql zabbix
    # stop here if you are creating database for Zabbix proxy
    shell> cat images.sql | sudo -u zabbix psql zabbix
    shell> cat data.sql | sudo -u zabbix psql zabbix

::: noteimportant
The above commands are provided as an example that
will work in most of GNU/Linux installations. You can use different
commands, e. g. "psql -U <username>" depending on how your
system/database are configured. If you have troubles setting up the
database please consult your Database administrator. 
:::

[comment]: # ({/new-61d6043c})

[comment]: # ({cc68ca58-cc68ca58})
#### TimescaleDB

Інструкції щодо створення та налаштування TimescaleDB наведено в окремому [розділі](/manual/appendix/install/timescaledb).

[comment]: # ({/cc68ca58-cc68ca58})

[comment]: # ({7b4d56a7-7b4d56a7})
#### Oracle

Інструкції щодо створення та налаштування бази даних Oracle наведено в окремому [розділі](/manual/appendix/install/oracle).

[comment]: # ({/7b4d56a7-7b4d56a7})

[comment]: # ({870c2e3b-02d49e4f})
#### SQLite

Використання SQLite підтримується лише для **Zabbix proxy**!

База даних буде створена автоматично, якщо вона не існує.

Поверніться до [розділу встановлення](/manual/installation/install).

[comment]: # ({/870c2e3b-02d49e4f})
