cacti 的 “FATAL: Cannot connect to MySQL server on 'localhost'” 错误


Cacti 的 MySQL server on 'localhost'” 错误_第1张图片


[root@nagios cacti]# php poller.php 

FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'

当mysql中的所有配置和cacti的config.php都正确,却还是出现该错误时,那就是mysql套接字的原因了~  cacti会自动的去查找/var/lib/mysql/mysql.sock 该套接字,但是如果是源码安装的mysql,未指定套接字位置时,套接字的位置为/tmp/mysql.sock,由于cacti未找到/var/lib/mysql/mysql.sock,所以显示的是“Cannot connect to MySQL server on 'localhost'”