mysql_connect() [function.mysql-connect]: Can't connect to l

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

Moderators: Developers, Moderators

Post Reply
anilreddyv
Posts: 2
Joined: Tue Jul 25, 2006 3:29 pm

mysql_connect() [function.mysql-connect]: Can't connect to l

Post by anilreddyv »

Hi,

I have installed Cacti as per instructions from RPM's but I am having following error when I try to connect to http://192.168.1.11/cacti/

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 339

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 339


RPMS installed

bash-3.00# rpm -qa|grep mysql
mysql-devel-4.1.11-2
php-mysql-5.1.2-4.EL40
-bash-3.00# rpm -qa|grep php
php-mysql-5.1.2-4.EL40
php-5.1.2-4.EL40
-bash-3.00# rpm -qa|grep net-snmp
net-snmp-libs-5.1.2-11
net-snmp-5.1.2-11
net-snmp-devel-5.1.2-11
-bash-3.00#

I am able to connect to mysql from cactiuser

-bash-3.00# mysql --user cactiuser --password
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 5.0.18-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Thanks in advance for your help.

Regards
Anil
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Try using the IP address in config.php instead of localhost. Seems odd. Also, post the output from the following:

php -m

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
anilreddyv
Posts: 2
Joined: Tue Jul 25, 2006 3:29 pm

Post by anilreddyv »

Thanks for reply. But no change having IP address in config.php, it ends up with same error

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "192.168.1.11";
$database_username = "cactiuser";
$database_password = "cactipw";


mysql> GRANT ALL ON cactidb.* TO cactiuser@192.168.1.11;
Query OK, 0 rows affected (0.00 sec)


-bash-3.00# php -m
[PHP Modules]
bcmath
bz2
calendar
ctype
curl
date
dba
dom
exif
ftp
gd
gettext
gmp
hash
iconv
libxml
mbstring
mysql
ncurses
openssl
pcre
PDO
pdo_sqlite
posix
pspell
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
SQLite
standard
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

-bash-3.00#
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Interesting. I don't have a clue :(
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
bali-boy
Posts: 12
Joined: Wed Sep 06, 2006 8:20 pm

Post by bali-boy »

"i do have same problem with you when i try to installing cacti for the first time ....i do the same way to call cacti by typing "http://<ip number>/cacti/" , but it's doesn't work....and then i found in the apache config file (httpd.conf) there's a line that told about DocumentRoot, which default is "/usr/local/apache2/htdocs/".....so i move all my cacti folder into it.....and then i start again from scratch to create cacti database.....and change the crontab, to locate the poller into new location...and retype "chown -R cactiuser /../../{rra,log}" in new folder of cacti....good luck :D :D :D "
ppat72
Posts: 1
Joined: Fri Sep 08, 2006 1:10 pm

Re: mysql_connect() [function.mysql-connect]: Can't connect

Post by ppat72 »

I was having the same problem. when i tried to connect to mysql from command line using below command
# mysql --user=cactiuser --password=eikd$idj
that also gave me same error

So i figure out the culprit is in the way i have choosen the password.

You should not use any characters like $, # & etc..in your password.

But if you do use it than use escape character in front of it. eg
# mysql --user=cactiuser --password=eikd\$idj

accordingly you have to change your include/config.php where you have use the password..


Hope this help...

Pratish
anilreddyv wrote:Hi,

I have installed Cacti as per instructions from RPM's but I am having following error when I try to connect to http://192.168.1.11/cacti/

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 339

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 339


RPMS installed

bash-3.00# rpm -qa|grep mysql
mysql-devel-4.1.11-2
php-mysql-5.1.2-4.EL40
-bash-3.00# rpm -qa|grep php
php-mysql-5.1.2-4.EL40
php-5.1.2-4.EL40
-bash-3.00# rpm -qa|grep net-snmp
net-snmp-libs-5.1.2-11
net-snmp-5.1.2-11
net-snmp-devel-5.1.2-11
-bash-3.00#

I am able to connect to mysql from cactiuser

-bash-3.00# mysql --user cactiuser --password
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 5.0.18-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Thanks in advance for your help.

Regards
Anil
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests