I got an Error saying Your database is out of date! ./lnms migrate after i upgrade my Ubuntu server from 18.04 to 20.04

when i run ./validate.php
$ ./validate.php & ./lnms.migrate

Component Version
LibreNMS 22.10.0-82-g26318dc4b (2022-11-05T19:43:54+00:00)
DB Schema 2020_08_28_212054_drop_uptime_column_outages (175)
PHP 8.1.12
Python 3.8.10
Database MariaDB 10.3.34-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2
SNMP 5.8

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

[OK] Composer Version: 2.4.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate
Attempt to fix this issue (y or n)?:y

In Connection.php line 712:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ already ex
ists (SQL: create table cache (key varchar(255) not null, value text not nu
ll, expiration int not null) default character set utf8mb4 collate ‘utf8mb4_uni
code_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ already ex
ists

In PDOStatement.php line 117:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ already ex
ists
#######################################################################
root@librenms:/opt/librenms# sudo systemctl status mysql
● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; generated)
Active: active (running) since Sun 2022-11-06 04:17:56 UTC; 9s ago
Docs: man:systemd-sysv-generator(8)
Process: 39860 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
Tasks: 34 (limit: 11846)
Memory: 97.5M
CGroup: /system.slice/mysql.service
├─39899 /bin/sh /usr/bin/mysqld_safe
├─40016 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/x86_64-linux-gnu/mariadb19/plugin --user=mysql --skip-log-error --pid-file=/run/m>
└─40017 logger -t mysqld -p daemon error

Nov 06 04:17:55 librenms mysqld[40017]: Version: ‘10.3.34-MariaDB-0ubuntu0.20.04.1’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 Ubuntu 20.04
Nov 06 04:17:55 librenms mysqld[40017]: 2022-11-06 4:17:55 0 [Note] InnoDB: Buffer pool(s) load completed at 221106 4:17:55
Nov 06 04:17:56 librenms mysql[39860]: …done.
Nov 06 04:17:56 librenms systemd[1]: Started LSB: Start and stop the mysql database server daemon.
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: /usr/bin/mysql_upgrade: the ‘–basedir’ option is always ignored
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: Looking for ‘mysql’ as: /usr/bin/mysql
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: Looking for ‘mysqlcheck’ as: /usr/bin/mysqlcheck
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: This installation of MariaDB is already upgraded to 10.3.34-MariaDB.
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: There is no need to run mysql_upgrade again for 10.3.34-MariaDB.
Nov 06 04:17:56 librenms /etc/mysql/debian-start[40074]: You can use --force if you still want to run mysql_upgrade
lines 1-22/22 (END)

Please help i tried my 2 days and could not fixed this.

Easiest way would be to drop the cache table, then migrate. (The cache table does not contain any important data ever)

Thank you so much for your reply . But i get those error when i attempt this method .

MariaDB [(none)]> use librenms;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [librenms]> CREATE TABLE port_group_port (
→ port_group_id int(10) unsigned NOT NULL,
→ port_id int(10) unsigned NOT NULL,
→ PRIMARY KEY (port_group_id,port_id),
→ KEY port_group_port_port_group_id_index (port_group_id),
→ KEY port_group_port_port_id_index (port_id),
→ CONSTRAINT port_group_port_port_group_id_foreign FOREIGN KEY (port_group_ id) REFERENCES port_groups (id) ON DELETE CASCADE,
→ CONSTRAINT port_group_port_port_id_foreign FOREIGN KEY (port_id) REFERENC ES ports (port_id) ON DELETE CASCADE
→ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ERROR 1005 (HY000): Can’t create table librenms.port_group_port (errno: 150 “Foreign key constraint is incorrectly formed”)
MariaDB [librenms]> quit
Bye
admin_manohar@librenms:~$ ./lnms migrate
-bash: ./lnms: No such file or directory
admin_manohar@librenms:~$ su librenms
Password:
su: Authentication failure
admin_manohar@librenms:~$ su librenms
Password:
su: Authentication failure
admin_manohar@librenms:~$ sudo su librenms
$ ./validat
sh: 1: ./validat: not found
$ ^[[Ae^[[A^C
$ ./lnms migrate
sh: 2: ./lnms: not found
$ ./lnms migrate
sh: 3: ./lnms: not found
$ exit
admin_manohar@librenms:~$ sudo su
root@librenms:/home/admin_manohar# su librenms
$ ./lnms migrate
sh: 1: ./lnms: not found
$ exit
root@librenms:/home/admin_manohar# cd /opt/librenms
root@librenms:/opt/librenms# su librenms
$ ./lnms migrate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Migrating: 2020_09_18_223431_create_cache_table

In Connection.php line 712:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ alre
ady exists (SQL: create table cache (key varchar(255) not null, value
text not null, expiration int not null) default character set utf8mb4 co
llate ‘utf8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ alre
ady exists

In PDOStatement.php line 117:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘cache’ alre
ady exists

Im new to Linux so please provide me the whole steps if possible…
Thanks.

You started up the mysql command line, but didn’t drop the cache table as I advised.

Just DROP TABLE cache; in the mysql cli, then lnms migrate as you did before.

Thank you so much Murrant . I really Appreciate the work you are doing .I saw your great contribution on Libre . Actually, I retired that old Server Running LibreNms after spending 40 hour to solve that issue and could not succeed . Currently, Migrading all the devices to the new LibreNMS . But i will turn up that VM and try again .If succeed then it will be easy for us to gain old RRD data too. FYI , I have sent you a small amount last week on sunday through Paypal.
Have a great weekend and Thanks for replying .

Thanks for the donation @Manohar_Acharya I saw it come through but didn’t know who sent it. :slight_smile: