cacti can't connect to mysql (checked everything)

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

cacti can't connect to mysql (checked everything)

Post by blacksun »

The problem is that the log file says:
12/27/2005 11:45:07 PM - CMDPHP: Poller[0] ERROR: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'.

This is what I did:
installed cacti with yast:
cp -rp /usr/share/cacti /srv/www/htdocs/cacti

php.ini
register_globals = On
register_argc_argv = On

config:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "root";
$database_password = "";

MYSQL:
mysql -u root
create database cacti
exit
mysql -u root cacti < /usr/share/cacti/cacti.sql
mysql -u root
use cacti
GRANT ALL PRIVILEGES ON cacti.* TO 'root'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '';
SHOW TABLES gives content.....
flush privileges;

I tried everything; $database_hostname = "localhost"; doesn't help either.
Very annoying; i do something wrong.... but what..
Last edited by blacksun on Tue Dec 27, 2005 6:15 pm, edited 1 time in total.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Does the web interface work?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

yes.
I'm following this http://www.cacti.net/downloads/docs/htm ... graph.html
tutorial to test.

I've installed rddtool and all other software.
Last edited by blacksun on Thu Dec 29, 2005 12:31 pm, edited 1 time in total.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

What OS?

Are you running mysql in a chroot?

Is networking enabled for the mysql server?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

suse 10.0 both apache2 and mysql running.
(no not running in chroot)
yes.
JJX
Cacti User
Posts: 402
Joined: Thu Oct 06, 2005 5:03 am

Post by JJX »

are u running poller as root?

give us the output of ls -la /usr/share/cacti /srv/www/htdocs/cacti

also try 127.0.0.1 instead of localhost
(maybe /etc/hosts doesnt match localhost --> 127.0.0.1 for some reason)
cacti rulez!
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

peter@peter:~> cat /etc/hosts
127.0.0.1 localhost
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
192.168.1.5 peter.x.nl peter


ls -al /srv/www/htdocs/cacti/poller.php
-rw-r--r-- 1 root root 9247 2005-09-09 20:54 /srv/www/htdocs/cacti/poller.php

ls -al /usr/share/cacti/poller.php
-rw-r--r-- 1 root root 9247 2005-09-09 20:54 /usr/share/cacti/poller.php

vim /etc/sysconfig/apache2
APACHE_MODULES="access actions alias auth autoindex cgi dir include log_config mime negotiation setenvif status userdir asis
imap php4 auth_mysql"

crontab -e as root:
*/5 * * * * root php /srv/www/htdocs/cacti/poller.php > /dev/null 2>&1

If i run as root php /srv/www/htdocs/cacti/poller.php it generates graphs..
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

suggestions?
I've written a small php file which connects to the mysql database
and does a query.
it succeeds.
so it has something to do with the config.

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "";
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

please reply to this post; i'm willing to give you guys all the information you need.
blacksun
Posts: 9
Joined: Tue Dec 27, 2005 5:50 pm

Post by blacksun »

well i solved it; apparently; something with user rights;
just leave the files in /usr/share/cacti; and everything works.\
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests