Hello Cacti forum members
I have an existing Cacti installation running on Centos 6.9, PHP 5.3.3, MySQL 14.14 and Cacti version 0.8.8h. The OS is current with patches and updates. This setup has been running fine, for nearly 4 years. It started on Cacti 0.8.8c and it has been upgraded every couple of versions, to version 0.8.8h. No significant problems with previous upgrades. When I attempt to upgrade to *any* of the 1.x Cacti versions, I always receive the "FATAL: Connection to Cacti database failed. Please ensure the database is running and your credentials in config.php are valid." error.
I have checked, rechecked and verified the MySQL login credentials set in the /include/config.php file. They are exactly the same as used in the 0.8.8h version, where they work fine. I can also use these credentials via MySQL CLI and log in to the database, with no problem. Using these credentials, I can make SELECT statements from tables in the Cacti database and so on, all from the CLI. There doesn't appear to be an issue with the credentials, despite what the error messages says. The database is running. No other applications are having difficulty accessing it.
I have looked in the Apache error_log and can find nothing relevant listed there. Perhaps, I need to set up the severity level of the logging? In addition to that, I have reviewed the information posted here: http://kedar.nitty-witty.com/blog/canno ... acti-error I followed the steps contained in this posting, to no avail. The suggested workaround - Changing $database_hostname to 127.0.0.1 in include/config.php, made no difference for me. Still getting the error. I would think that if there were socket config problems with MySQL, the issue would affect other applicatons, which it doesn't.
I've also read various threads on this forum that relate to this error, but solutions I've found, don't seem to apply to my issue.
What are the differences, in how Cacti versions 1.x and higher access the database, when compared to previous versions? Anyone, have any further suggesions on troubleshooting this db connection problem?
Thanks for reading my post!
tb
DB connection fails, when upgrading from 0.8.8h to 1.x
Moderators: Developers, Moderators
-
- Posts: 1
- Joined: Thu Dec 14, 2017 10:57 am
Re: DB connection fails, when upgrading from 0.8.8h to 1.x
With version 1.x of Cacti, the move from ADOConnection to PDO was made. You can find more information about that at http://php.net/manual/en/ref.pdo-mysql.php
db_connect_real() in 0.8.8 used:
where db_connect_real() in 1.1.28 uses:
db_connect_real() in 0.8.8 used:
Code: Select all
$dsn = "$db_type://" . rawurlencode($user) . ":" . rawurlencode($pass) . "@" . rawurlencode($host) . "/" . rawurlencode($db$
if ($db_ssl && $db_type == "mysql") {
$dsn .= "&clientflags=" . MYSQL_CLIENT_SSL;
}elseif ($db_ssl && $db_type == "mysqli") {
$dsn .= "&clientflags=" . MYSQLI_CLIENT_SSL;
}
if ($port != "3306") {
$dsn .= "&port=" . $port;
}
$cnn_id = ADONewConnection($dsn);
Code: Select all
if (file_exists($device)) {
$cnn_id = new PDO("$db_type:unix_socket=$device;dbname=$db_name;charset=utf8", $user, $pass, $flags$
} else {
$cnn_id = new PDO("$db_type:host=$device;port=$port;dbname=$db_name;charset=utf8", $user, $pass, $f$
}
Cacti Developer & Release Manager
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
The Cacti Group
Director
BV IT Solutions Ltd
+--------------------------------------------------------------------------+
Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Who is online
Users browsing this forum: No registered users and 1 guest