Remote MySQL server issue

Hi Guys,

I’m having an odd problem when trying to use a remote MySQL server for the db.

The connection to the server works fine, validate confirms that as per below.

====================================

Component Version
LibreNMS 1.42.01-21-g32f8a297e
DB Schema 258
PHP 7.1.20-1+ubuntu18.04.1+deb.sury.org+1
MySQL 5.7.23-0ubuntu0.18.04.1
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

[OK] Composer Version: 1.7.1
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

Here is my config.php relevant info also,

$config[‘db_host’] = ‘librenms-ctrl.XXXXX.net’;
$config[‘db_port’] = ‘3306’;
$config[‘db_user’] = ‘librenms’;
$config[‘db_pass’] = ‘XXXXXXXXXXXX’;
$config[‘db_name’] = ‘librenms’;
$config[‘db_socket’] = ‘’;

I ran tcp dump on the MySQL remote server which shows activity when validate runs. I can also log into the remote MySQL server from the local server with the credentials I’ve configured.

The host name can be found using nslookup locally so it is configured correctly and pointing to the correct IP.

When I try browse to the lIbrenms webui I get a MySQL error. No connection to localhost. Is there anywhere else i should be changing dbhost info? It still looking for localhost.

In apache, the error logs shows this.

production.ERROR: LibreNMS\Exceptions\DatabaseConnectException: Could not connect to localhost in /opt/librenms/includes/dbFacile.php:86.

Line 86 is within this

$database_link = @mysqli_connect(‘p:’ . $db_host, $db_user, $db_pass, null, $db_port, $db_socket);
if ($database_link === false) {
$error = mysqli_connect_error();
if ($error == ‘No such file or directory’) {
$error = 'Could not connect to ’ . $db_host;
}
throw new DatabaseConnectException($error);
}

Shouldnt DB host now be the remote server and not the localhost? Am i missing a place to enter the dbhost somewhere?

It was initially configured as localhost when it was first installed but I’ve made post install changes as per above. Any help is appreciated!

Ciaran

Edit your .env file too (In /opt/librenms)

Ive edited that so it reference the remote server and remote user pass.

WIth mysql server installed on the local server i get Access denied for user ‘librenms’@‘localhost’ (using password: YES) .

When its not installed I get connection refused.

I still dont see activity with tcp dump enabled on the mysql server when i refresh the page.

Ill keep trying i guess!

Ciaran

The only two places you need to update your auth details are config.php and .env. If you have the correct credentials then all should be well. You can test with mysql -u librenms -p -h HOSTNAME

Thanks guys, made a small error in the .env file which is sorted and all is good. Thanks for your help, both of you.

Mind sharing what was wrong?