Upgrade ubuntu 16.04 to 18.04 - DB Issue


#1

I upgrade from Ubuntu 16.04 to 18.04 and now it say Could not connect to database when I validate. PHP validate as follows:

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

Component Version
LibreNMS 1.48.1-4-g57aec11aa
DB Schema Not Connected (0)
PHP 7.0.32-0ubuntu0.16.04.1
MySQL ?
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

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

[OK] Composer Version: 1.8.3
[OK] Dependencies up-to-date.
Could not connect to database, check logs/librenms.log.

Appreciate any help to restore database


#2

https://docs.librenms.org/Support/FAQ/#where-do-i-update-my-database-credentials


#3

Thanks @murrant .I didn’t change my Database configuration. I can see on the config.php that it stays intact. I upgrade my Ubuntu server from 16.04 to 18.04 and I remember there was prompt during the upgrade about the mariaDB which I chose the option to go with the newer version or something of that sort


#4

I would check your my.cnf is correct and check mariadb is running, check database still accessible using librenms db connection details

e.g

mysql -u username -p
SHOW DATABASES;

#5

Which my.cnf you referring to ? The /opt/librenms/config.php ?

MySQL and MariaDB packages after the upgrade shows the following:

ii libdbd-mysql-perl 4.046-1 amd64 Perl5 database interface to the MariaDB/MySQL database
ii libmysqlclient20:amd64 5.7.25-0ubuntu0.18.04.2 amd64 MySQL database client library
ii mariadb-client 1:10.1.34-0ubuntu0.18.04.1 all MariaDB database client (metapackage depending on the latest version)
rc mariadb-client-10.0 10.0.36-0ubuntu0.16.04.1 amd64 MariaDB database client binaries
ii mariadb-client-10.1 1:10.1.34-0ubuntu0.18.04.1 amd64 MariaDB database client binaries
ii mariadb-client-core-10.1 1:10.1.34-0ubuntu0.18.04.1 amd64 MariaDB database core client binaries
ii mariadb-common 1:10.1.34-0ubuntu0.18.04.1 all MariaDB common metapackage
ii mariadb-server 1:10.1.34-0ubuntu0.18.04.1 all MariaDB database server (metapackage depending on the latest version)
rc mariadb-server-10.0 10.0.36-0ubuntu0.16.04.1 amd64 MariaDB database server binaries
ii mariadb-server-10.1 1:10.1.34-0ubuntu0.18.04.1 amd64 MariaDB database server binaries
ii mariadb-server-core-10.1 1:10.1.34-0ubuntu0.18.04.1 amd64 MariaDB database core server files
ii mysql-common 5.8+1.0.4 all MySQL database common files, e.g. /etc/mysql/my.cnf
rc php7.0-mysql 7.0.32-0ubuntu0.16.04.1 amd64 MySQL module for PHP
ii python-mysqldb 1.3.10-1build1 amd64 Python interface to MySQL

MySQL status shows this:
mariadb.service - MariaDB 10.1.34 database server

I tried to use the credentials in /opt/librenms/config.php for “mysql -u username -p” and came up with this error

ERROR 1045 (28000): Access denied for user ‘username’@‘localhost’ (using password: YES)


#6

Looks like you need to figure out what your database credentials are.


#7

Both the check the config.php and .env have the same settings with DB name, username and password


#8

Running mysql -u root -p -e ‘show databases’ with the librenms DB password shows this result

±-------------------+
| Database |
±-------------------+
| information_schema |
| librenms |
| mysql |
| performance_schema |
±-------------------+


Installation PHP7.2 Ubuntu 16 problems
#9

Had this issue as well. What I did was the following:

Installed the following again:
apt install curl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.2-cli php7.2-curl php7.2-fpm php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-snmp php7.2-xml php7.2-zip python-memcache python-mysqldb rrdtool snmp snmpd whois

After this I changed the time.zone in php files:

vi /etc/php/7.2/fpm/php.ini
vi /etc/php/7.2/cli/php.ini

systemctl restart php7.2-fpm

and changed the Php version in librenms.conf. I changed it in nginx folder

This solved my problem.


#10

Don’t long in with root, log in with the credentials in the files (.env & config.php). You said that failed earlier. You need to check to see if they actually work.


#11

Thanks @Bob_Puts. That step fixes it for me, however Ive got it on Apache. So for me the steps are as follows:

  1. Upgrade to Ubuntu 18.04.2 LTS - do-release-upgrade

  2. Install the package again:
    apt install curl apache2 composer fping git graphviz imagemagick libapache2-mod-php7.2 mariadb-client mariadb-server mtr-tiny nmap php7.2-cli php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-snmp php7.2-xml php7.2-zip python-memcache python-mysqldb rrdtool snmp snmpd whois

  3. Change time zone in php files in :
    /etc/php/7.2/cli/php.ini
    /etc/php/7.2/apache2/php.ini

  4. Reboot my server

Of couse I have to run ./validate php and fix certain things that needs to be fixed which is self explanatory on the result :slight_smile:


URGENT HELP - Upgrade to Ubuntu 18.04 killed LibreNMS!