Astervis Docs

MySQL Configuration

Configure connection to your PBX CDR database

Astervis connects to your PBX's MySQL database to sync CDR (Call Detail Records) in real-time.

Auto-Detection

The installer automatically detects MySQL credentials for supported PBX systems:

PBXConfig File
FreePBX/etc/freepbx.conf
Sangoma PBXact/etc/freepbx.conf
Issabel/etc/issabel.conf
VitalPBX/etc/vitalpbx/vitalpbx.conf

If auto-detection fails or you're using generic Asterisk, configure manually.

Manual Configuration

Edit /opt/astervis/.env:

MYSQL_HOST=host.docker.internal
MYSQL_PORT=3306
MYSQL_USER=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_DB=asteriskcdrdb
MYSQL_USERS_DB=asterisk
MYSQL_TIMEZONE=Europe/Moscow

Host Options

ValueWhen to Use
host.docker.internalMySQL runs on the same server (default)
192.168.1.100MySQL on a different server
localhostWon't work from Docker containers

Don't use localhost — Docker containers can't reach it. Use host.docker.internal for local MySQL.

Binary Logging (Required)

Real-time sync requires MySQL binary logging enabled. Check if it's enabled:

mysql -u root -p -e "SHOW VARIABLES LIKE 'log_bin';"

If OFF, enable it:

FreePBX / Sangoma

sudo nano /etc/my.cnf

Add under [mysqld]:

[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_format = ROW
binlog_row_image = FULL
expire_logs_days = 7

Restart MySQL:

sudo systemctl restart mariadb
# or
sudo fwconsole restart

Ubuntu / Debian

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Add under [mysqld]:

[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_format = ROW
binlog_row_image = FULL
expire_logs_days = 7

Restart MySQL:

sudo systemctl restart mysql

Database User Permissions

The MySQL user needs these permissions:

GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT
ON *.* TO 'astervis_cdc'@'%';
 
GRANT SELECT ON asteriskcdrdb.* TO 'astervis_cdc'@'%';
GRANT SELECT ON asterisk.* TO 'astervis_cdc'@'%';
 
FLUSH PRIVILEGES;

The installer creates these permissions automatically if you provide root credentials.

CDR Table Structure

Astervis expects the standard Asterisk CDR table:

-- Required columns
calldate     DATETIME       -- Call timestamp
src          VARCHAR        -- Source number
dst          VARCHAR        -- Destination number
duration     INT            -- Total duration (seconds)
billsec      INT            -- Billable duration (seconds)
disposition  VARCHAR        -- ANSWERED, NO ANSWER, BUSY, FAILED
uniqueid     VARCHAR        -- Unique call ID

Testing Connection

After configuration, test the connection:

sudo astervis-installer test-mysql

Troubleshooting

Connection Refused

Error: connect ECONNREFUSED

Solutions:

  • Check MySQL is running: systemctl status mysql
  • Verify host is host.docker.internal not localhost
  • Check firewall allows port 3306

Access Denied

Error: Access denied for user

Solutions:

  • Verify credentials in .env
  • Check user has required permissions
  • Try connecting manually: mysql -h 127.0.0.1 -u user -p

Binary Log Not Enabled

Error: Binary log is not enabled

Solution: Enable binary logging (see above).

Wrong Timezone

Calls appear with wrong times.

Solution: Set MYSQL_TIMEZONE to match your PBX server timezone. See Timezone Configuration.

On this page