Se encuentra viendo la documentación de la versión en desarrollo, puede estar incompleta.
Únase a nuestro proyecto de traducción y ayude a traducir la documentación de Zabbix a su lengua materna.

1 MySQL/MariaDB

Overview

This section contains best practices for setting up a MySQL database in a secure way.

For an easy setup, it is recommended to follow the default MySQL/MariaDB database creation instructions, which include creating the 'zabbix' user with full privileges on the Zabbix database. This user is the database owner that also has the necessary privileges for modifying the database structure when upgrading Zabbix.

To improve security, creating additional database roles and users with minimal privileges is recommended. These roles and users should be configured based on the principle of least privilege, that is, they should only have privileges that are essential for performing the intended functions.

Creating user roles

Create the following roles with the corresponding privileges:

  • zbx_srv - role for running Zabbix server and proxy:
create role 'zbx_srv';
       grant delete, insert, select, update on zabbix.* to 'zbx_srv';
       flush privileges;
  • zbx_web - role for running Zabbix frontend and API:
create role 'zbx_web';
       grant delete, insert, select, update on zabbix.* to 'zbx_web';
       flush privileges;
  • zbx_bckp - role for table backup:
create role 'zbx_bckp';
       grant lock tables, trigger, select on zabbix.* to 'zbx_bckp';
       grant process on *.* to 'zbx_bckp';
       flush privileges;

Table restoration should be performed by the database owner.

  • zbx_part - role with a reduced set of privileges for database partitioning; note that this role can be created only after the database has been created, as it grants privileges on specific database tables:
create role 'zbx_part';
       grant select, alter, drop on zabbix.history to 'zbx_part';
       grant select, alter, drop on zabbix.history_uint to 'zbx_part';
       grant select, alter, drop on zabbix.history_str to 'zbx_part';
       grant select, alter, drop on zabbix.history_text to 'zbx_part';
       grant select, alter, drop on zabbix.history_log to 'zbx_part';
       grant select, alter, drop on zabbix.trends to 'zbx_part';
       grant select, alter, drop on zabbix.trends_uint to 'zbx_part';
       -- For MariaDB: skip the next line (grant session_variables_admin on *.* to 'zbx_part';)
       grant session_variables_admin on *.* to 'zbx_part';
       grant select on zabbix.dbversion to 'zbx_part';
       grant select,delete on zabbix.housekeeper to 'zbx_part';
       flush privileges;

After creating roles, they can be assigned to users.

Assigning user roles

To assign the created user roles, create users and assign the relevant roles to them. Replace <user>, <host>, <role>, and <password> as necessary.

create user '<user>'@'<host>' identified by '<password>';
       grant '<role>' to '<user>'@'<host>';
       set default role '<role>' to '<user>'@'<host>';
       -- For MariaDB: set default role '<role>' for '<user>'@'<host>'
       flush privileges;

For example, to create and assign the role for running Zabbix server and proxy:

create user 'usr_srv'@'localhost' identified by 'password';
       grant 'zbx_srv' to 'usr_srv'@'localhost';
       set default role all to 'usr_srv'@'localhost';
       flush privileges;