Skip to content

Icinga2 IDO MySQL Connection Error — Quick Fix

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Icinga2 IDO MySQL Connection Error. We cover key concepts, practical examples, and best practices.

The Problem

Icinga2's IDO (Icinga Data Output) module cannot connect to the MySQL database. Monitoring data is not being written to the database, and the Icingaweb2 UI shows stale or no data. The IDO connection may drop periodically.

Error example:

Error: IDO MySQL: Cannot connect to MySQL server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Error: IDO MySQL: Database 'icinga2' does not exist or is not accessible
Error: IDO MySQL: Schema version mismatch. Expected 2.0.0, got 1.0.0

The Fix

Step 1: Check the IDO configuration

WRONG — only restarting Icinga2 when the database is inaccessible:

# Restarting will not fix a database connection issue

RIGHT — verify the IDO configuration:

grep -A 10 'mysql' /etc/icinga2/features-available/ido-mysql.conf

Output:

library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
  host = "localhost"
  port = 3306
  user = "icinga2"
  password = "icinga2"
  database = "icinga2"
}

Step 2: Fix database schema issues

WRONG — skipping schema migrations:

# Schema version mismatch will prevent IDO from working

RIGHT — upgrade the schema:

# Find the schema upgrade script
mysql -u icinga2 -p icinga2 < /usr/share/icinga2-ido-mysql/schema/upgrade/2.0.0.sql

# Verify schema version
mysql -u icinga2 -p icinga2 -e "SELECT version FROM icinga_dbversion;"

Output:

+---------+
| version |
+---------+
| 2.0.0   |
+---------+

Use DodaTech's IDO Database Auditor to check schema version, connection health, and write throughput for Icinga2 IDO connections.

Prevention Tips

  • Use a dedicated MySQL user for Icinga2 IDO with minimal privileges
  • Monitor IDO connection state with Icinga2's built-in health checks
  • Apply MySQL schema upgrades before upgrading Icinga2 itself
  • Configure connection timeouts to prevent stale connections
  • Use DodaTech's Database Migration Tool for automated schema upgrades

Common Mistakes with ido mysql

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world ICINGA2 code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What database options does Icinga2 IDO support?

Icinga2 IDO supports MySQL/MariaDB and PostgreSQL. The configuration format is slightly different for each. MySQL is the most common choice for Icinga2 deployments. PostgreSQL support was added in Icinga2 2.12.

Why does IDO MySQL disconnect after periods of high load?

The connection may time out due to long-running queries or MySQL's wait_timeout setting. Add connect_timeout = 30, reconnect = true, and persist = true to the IDO MySQL connection configuration to handle transient disconnections.

How do I know if IDO is connected and writing data?

Run icinga2 object list --type IdoMysqlConnection to check the connection status. The output shows whether the connection is established and how many queries have been executed. Monitor the "pending_queries" metric for write queue growth.

Related: DodaTech's Icinga2 Database Sizing Guide provides recommendations for MySQL configuration, storage sizing, and connection pooling for large-scale IDO deployments.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro