FATAL: Cannot connect to MySQL server on 'localhost'....

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
myfahim
Posts: 15
Joined: Sat Jan 21, 2012 1:33 am
Location: Dhaka, Bangladesh
Contact:

FATAL: Cannot connect to MySQL server on 'localhost'....

Post by myfahim »

My System: RHEL 5.5
Cacti Version: 0.8.8a and 0.8.7g

After setup when I try to browse, an error shows: FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'

Could anyone please help me regarding this.

Some Info related to my configuration:

Code: Select all

groupadd cacti
useradd -g cacti cactiuser

MySQL configuration:
set password for root@localhost=password('*****');
create database cactidb;
grant all on cactidb.* to root;
grant all on cactidb.* to root@localhost;
grant all on cactidb.* to cactiuser;
grant all on cactidb.* to cactiuser@localhost;
use cactidb;
set password for cactiuser@localhost=password('*****');
And in include/config.php:

Code: Select all

$database_type = "mysql";
$database_defaut = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “*****”;
With same configuration I have configured cacti one years ago. I can't understand why the error is showing. Please help me.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by gandalf »

Please try to login via mysql from cli using same credentials
R.
myfahim
Posts: 15
Joined: Sat Jan 21, 2012 1:33 am
Location: Dhaka, Bangladesh
Contact:

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by myfahim »

Thanks gandalf,

Every think is OK now. There was a spelling mistake "default" on include/config.php ("$database_defaut). HA HA HA..I know its funny.

Thanks for your reply.
mohamad61
Posts: 1
Joined: Tue Jan 28, 2014 12:30 am

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by mohamad61 »

1. Remove socket file:
[root@server ~]# rm /var/lib/mysql/mysql.sock
rm: remove socket `/var/lib/mysql/mysql.sock'? yes

2. Start MySQL service:
[root@server~]# service mysqld start
Starting mysqld: [ OK ]

Enjoy
incubusfreak
Posts: 1
Joined: Thu Dec 25, 2014 10:08 pm

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by incubusfreak »

i removed the sql sock and restart the mysqld
but still same issue
kakti
Posts: 1
Joined: Thu May 21, 2015 1:45 am

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by kakti »

I faced the issue and troubleshoot to find out the issue was with mysql socket file. You need to specify the mysql.default_socket=/path/to/mysql.sock in php.ini and restart apache.
I did a posted my troubleshooting steps here -> http://goo.gl/n5fEqh
Arsol
Posts: 1
Joined: Fri Oct 28, 2016 9:58 am

Re: FATAL: Cannot connect to MySQL server on 'localhost'....

Post by Arsol »

Don't use symbols $@.. in cacti user password in MYSQL.
In my case, this call FATAL: Cannot connect to MySQL server on 'localhost' .
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest