1 Database creation

Overview

A Zabbix database must be created during the installation of Zabbix server or proxy.

This section provides instructions for creating a Zabbix database. A separate set of instructions is available for each supported database.

UTF-8 is the only encoding supported by Zabbix. It is known to work without any security flaws. Users should be aware that there are known security issues if using some of the other encodings.

If installing from Zabbix Git repository, you need to run:

$ make dbschema

prior to proceeding to the next steps.

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.

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

If you are installing from Zabbix packages, stop here and continue with instructions for RHEL/CentOS or Debian/Ubuntu 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):

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

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):

  1. 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).

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

If you are installing from Zabbix packages, stop here and continue with instructions for RHEL/CentOS or Debian/Ubuntu 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).

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

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.

TimescaleDB

Instructions for creating and configuring TimescaleDB are provided in a separate section.

Oracle

Instructions for creating and configuring Oracle database are provided in a separate section.

SQLite

Using SQLite is supported for Zabbix proxy only!

If using SQLite with Zabbix proxy, database will be automatically created if it does not exist.

  1. shell> cd database/sqlite3
  2. shell> sqlite3 /var/lib/sqlite/zabbix.db < schema.sql

Return to the installation section.