联系我们:416326801#qq.com(#改成@)

Latest from the blog

Cacti配置远程MySQL

标签: MySQL Cacti

一共需要修改三处:

其中两处比较好找,分别在/var/www/html/include/config.php/var/www/html/include/global.php

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "mysql.cacti";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

最后一处在/etc/spine.conf,Cacti有数据但是图像一直空白也有可能是这个原因造成的!

DB_Host         mysql.cacti
DB_Database     cacti
DB_User         cactiuser
DB_Pass         cactiuser
DB_Port         3306
DB_PreG         0

Cacti修改MySQL数据库默认字符集

标签: MySQL Cacti

找到/var/www/html/lib/adodb/drivers/adodb-mysql.inc.php

在mysql_select_db之后增加"set names utf8"

function SelectDB($dbName) {
    $this->databaseName = $dbName;
    if( $this->_connectionID ) {
        $select = @mysql_select_db($dbName, $this->_connectionID);
        if( $select ) {
            return mysql_query("set names utf8");
        }
        return false;
    } else
        return false;
}


MySQL字符集latin1导出中文乱码

标签: MySQL Cacti

MySQL字符集latin1导出中文乱码,转换成utf8,以下是Cacti数据库导出转换示例。

若utf8编码在phpmyadmin中文正常,但Cacti页面显示乱码,则需要在mysql_select_db之后增加"set names utf8"

mysqldump -u root  --default-character-set=latin1 cacti > cacti_20170116.sql
sed -e 's/SET NAMES latin1/SET NAMES utf8/g' -i  cacti_20170116.sql 
sed -i -e 's/CHARSET=latin1/CHARSET=utf8 COLLATE=utf8_unicode_ci/g'  cacti_20170116.sql