但是发现修改config.php中的port不起作用, cacti依然选择去连接3306端口的数据库.
一番研究下, 发现cacti使用adodb来连接mysql, 并且默认使用的driver是php5-mysql, 使用NewADOConnection('mysql')的方式来连接mysql数据库.
而这个driver就我查到的看来是不支持非3306端口的连接. 并且cacti中连接mysql部分的函数的写法也是不支持其他端口, 因为在函数参数中hard code了3306.(不知道为何这么操作)
最终做了两处修改:
1. 修改[cacti_path]/lib/database.php, 使其能够接收port参数
function db_connect_real($host, $user, $pass, $db_name, $db_type, $port = "3306", $db_ssl = false, $retries = 20) {
global $cnn_id;
$i = 0;
$dsn = "$db_type://$user:$pass@$host/$db_name?persist&port=$port";
2. 修改[cacti_path]/include/config.path, 改为使用mysqli来连接mysql数据库
$database_type = "mysqli";
这样就可以自由修改config.php中的port了.