BUG : Mysql on port other than 3306

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

Moderators: Developers, Moderators

Post Reply
romgo1
Posts: 9
Joined: Tue Mar 19, 2013 10:15 am

BUG : Mysql on port other than 3306

Post by romgo1 »

Hello,

I am trying to use a mysql server on port 3307 which is not standard.
When debuging the file lib/database.php I see that $port is ignored.

I added to the die option the $port parameter.


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

It seems that $port is ignored.

I'm trying to setup cacti-0.8.8a


Regards,
romgo1
Posts: 9
Joined: Tue Mar 19, 2013 10:15 am

Re: BUG : Mysql on port other than 3306

Post by romgo1 »

Seems that I'm wrong. $port is updated so that's not my issue.
sorry.
romgo1
Posts: 9
Joined: Tue Mar 19, 2013 10:15 am

Re: BUG : Mysql on port other than 3306

Post by romgo1 »

Ok, after one afternoon of looking arround I finally found the problem.
$port doesn't work (still use 3306 as default).

to use another port put the port number in the $host = '192.168.0.1:3307'

I'll create a bug report for this.

Regards,
thorli
Posts: 1
Joined: Fri Apr 29, 2016 2:33 am

Re: BUG : Mysql on port other than 3306

Post by thorli »

Hi,

I just ran into the same problem and the solution is quite simple if you know what you have to look for. In fact it's not a real bug of cacti, but a lack in the documentation of cacti, that cost me 1 hour of my valued time ;)

In our environment the SQL server for cacti is running on port 3307, setting the database settings config.php to something like this does not work:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cactiuser";
$database_password = "somepass";
$database_port = "3307";
$database_ssl = false;

The reason is that cacti is using the adodb library to handle database connections via dsn and the mysql driver for adodb simply does not support the "port" parameter. If you switch the $database_type to "mysqli" it works. That's it, simple isn't it?

$database_type = "mysqli";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cactiuser";
$database_password = "somepass";
$database_port = "3307";
$database_ssl = false;

Another pitfall usually using a non standard port for mysql is that you have to change the hostname from "localhost" to "127.0.0.1" (or any other local IP), using "localhost" usually ignores the port parameter and uses the standart port.

If you use another host you also have to change the permissions for the mysql cactiuser accordingly:

GRANT ALL ON cacti.* TO cactiuser@"127.0.0.1" IDENTIFIED BY "somepass";
FLUSH PRIVILEGES;

@Cacti Dev-Team...please update the documentation with a remark how to setup cacti for a non standard mysql port, i guess a lot of people would appreciate that!
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests