SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(2
55) null) default character set utf8mb4 collate âutf8mb4_unicode_ciâ)
In Exception.php line 18:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
In PDOStatement.php line 112:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
Do you really wish to run this command? (yes/no) [no]:
yes
CreatePortGroupsTable: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(255) null) default character set utf8mb4 collate âutf8mb4_unicode_ciâ
CreatePortGroupsTable: alter table port_groups add unique port_groups_name_unique(name)
MigrateToUtf8mb4: ALTER SCHEMA librenms DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
MigrateToUtf8mb4: select TABLE_NAME from information_schema.tables where table_schema = ?
MigrateToUtf8mb4: select * from information_schema.columns where table_schema = ? and CHARACTER_SET_NAME is not null and COLLATION_NAME is not null and (CHARACTER_SET_NAME != ? or COLLATION_NAME != ?)
RenameTonerTable: rename table toner to printer_supplies
In SchemaException.php line 86:
There is no column with name âtoner_idâ on table âprinter_suppliesâ.
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar
(255) null) default character set utf8mb4 collate âutf8mb4_unicode_ciâ)
In Exception.php line 18:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
In PDOStatement.php line 112:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
I had this problem because I had defined a custom VIEW in the database. This prevented the 2021_02_09_122930_migrate_to_utf8mb4 migration from working (SQLSTATE[HY000]: General error: 1347 âlibrenms.myviewâ is not of type âBASE TABLEâ) which blocked all the later migrations and led to this problem. Removing the view allowed the migration to work.
I only saw this when running lnms migrate in real mode (âpretend showed different errors similar to what others are seeing that is not the root cause).
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(2
55) null) default character set utf8mb4 collate âutf8mb4_unicode_ciâ)
In Exception.php line 18:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
In PDOStatement.php line 112:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table âport_groupsâ already exists
Currently unable to use librenms " Whoops, looks like something went wrong. Check your librenms.log."
Found similar error in my librenms.log:
Error in printer-supplies module. SQLSTATE[42S02]: Base table or view not found: 1146 Table âlibrenms.printer_suppliesâ doesnât exist (SQL: select * from printer_supplies where printer_supplies.device_id = 85 and printer_supplies.device_id is not null)
git fetch --tags && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
HEAD is now at 5f7682d4f Bump version to 21.4.0
and ./daily.sh execute without issue.
Running sudo -u librenms ./lnms migrate does not fix the issue, states âport_groupsâ already exists, etc.