Page 1 of 1

Error connecting to databases!

Posted: Wed Jun 15, 2011 3:02 pm
by teslanagios
Hard drive of our server crashed and we decided restore nagios(2011R1.3) using backup file:
  • 1-/usr/local/nagios and /usr/local/nagiosxi
    2-/etc/nagiosql
    3-dump of:
    3.1 table nagios
    3.2 table nagiosql
    3.3 table nagiosxi from postgres
First off, we installed fresh of CentOS 5.5, then was beginning to install xi-2011-latest.tar.gz (from tmp folder)
All was good till /E-importnagiosql:

Code: Select all

ERROR: Unable to login to NagiosQL on 'localhost' - exiting. If you have a proxy configured, this may be the cause of the problem.
But we haven’t any proxy, our server directly connected to internet and has real ip.
We decided to ignore the problem, manually was created the file - installed.importnagiosql ;) and installation was finished(after F and Z steps).

Nagios core was beginning to work, but nagiosxi wasn’t beginning to work, in all log file of nagiosxi/var/* we have only one record -
ERROR CONNECTING TO DATABASES!
We used restore_defaults.sh but without success.

We rewrote originals folders (/usr/local/nagios, /usr/local/nagiosxi, /etc/nagiosql) to our backups folders. Then were restored tables from dump files. After all this we still have error in all log file of nagiosxi/var/* -
ERROR CONNECTING TO DATABASES!

Re: Error connecting to databases!

Posted: Wed Jun 15, 2011 3:14 pm
by nscott
Can you login manually to the databases?

First try logging in to the mysql

mysql -u root -p'nagiosxi'

If that logs you in, then quit mysql, then try

mysql -u nagiosql -p'n@gweb' nagiosql

This should log you into the nagiosql database (given default credentials.)

If none of this works, try accessing the nagiosql database from root

mysql -u root -p'nagiosxi' nagiosql

If it says database does not exist, create the database and try your nagiosql database dump again.

Re: Error connecting to databases!

Posted: Wed Jun 15, 2011 3:18 pm
by teslanagios
nscott wrote:Can you login manually to the databases?
....
Yes,I can login manually to the databases, using mysql -u root -p'nagiosxi' and mysql -u nagiosql -p'n@gweb' nagiosql.

Re: Error connecting to databases!

Posted: Thu Jun 16, 2011 2:41 am
by teslanagios
I was wrong when I talked about the successful completion of:
mysql -u nagiosql -p'n@gweb' nagiosql

Code: Select all

[root@server ~]# mysql -u nagiosql -p'n@gweb' nagiosql
ERROR 1044 (42000): Access denied for user 'nagiosql'@'localhost' to database 'nagiosql'
After executing:

Code: Select all

mysql> grant all privileges on *.* to 'nagiosql'@'localhost' identified by 'n@gweb';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all privileges on *.* to 'ndoutils'@'localhost' identified by 'n@gweb';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
All began to work fine ;) Thanks for help!!!

Re: Error connecting to databases!

Posted: Thu Jun 16, 2011 3:30 pm
by nscott
Glad you got it back up!