SQL access denied for user 'root'@'localhost' after updates

My Icinga2 web interface (Administrator → System → Migrations and Administrator → System → About pages) is displaying this error following updates to all packages:

SQLSTATE[HY000] [1045] Access denied for user ‘root’@‘localhost’ (using password: YES)

There was initially no such error immediately after updating all packages. The Administrator → System → Migrations page prompted me to migrate the database schema, but that failed so I performed the schema migration manually (I’ve done this in the past with no issue).

mysql -u root -p icingaweb2 <usr/share/icingaweb2/schema/mysql-upgrades/2.12.0.sql
mysql -u root -p icingaweb2 -e “GRANT ALL ON icingaweb2.* TO icingaweb2@localhost”

I encountered the “access denied for user root@localhost” error via CLI so I changed my MySQL root user’s password and ran the manual schema migration command again with seemingly no problem. The SQLSTATE error in the web interface showed up after that.

Not sure where I went wrong and how much I should be concerned about this error. Is there any way to validate the schema migrations and how should I go about resolving this issue?

  • Version used (icinga2 --version): 2.14.0-1
  • Operating System and version: CentOS 7
  • Enabled features (icinga2 feature list): api, checker, command, ido-mysql, influxdb, mainlog, notification
  • Icinga Web 2 version: 2.12.1

Update: I just noticed that my web interface also displays this error when I try to login (my admin password is correct).

All configured authentication methods failed. Please check the system log or Icinga Web 2 log for more information.

Contents of /var/log/messages:

Dec 5 16:40:48 icinga2master1 icingaweb2[24229]: Icinga\Exception\AuthenticationException in /usr/share/php/Icinga/Authentication/User/DbUserBackend.php:231 with message: Failed to authenticate user “administrator” against backend “icingaweb2”. An exception was thrown: ← Zend_Db_Adapter_Exception in /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Db/Adapter/Pdo/Abstract.php:171 with message: SQLSTATE[HY000] [1045] Access denied for user ‘root’@‘localhost’ (using password: YES) ← PDOException in /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Db/Adapter/Pdo/Abstract.php:145 with message: SQLSTATE[HY000] [1045] Access denied for user ‘root’@‘localhost’ (using password: YES)

Any advice on how to proceed?

Ok, here’s the solution. I realized the /etc/icingaweb2/resources.ini file contains the MySQL passwords (did not know this during my initial troubleshooting). Had to update the following entry to include the NEW root MySQL password:

[icingaweb2]
type = “db”
db = “mysql”
host = “localhost”
port = “”
dbname = “icingaweb2”
username = “root”
password = “new_password”
charset = “”
persistent = “0”
use_ssl = “0”