How to delete library data in koha using command line

Sometimes you need to empty the all data (e.g. bibliographic, borrowers and transaction details)  from your Koha LMS without losing the configuration settings and authorized values, e.g. libraries, item types, patron categories, locations etc. Let us know how to delete data from koha instance/library.

Delete koha bibliographic data

NB: I would recommend to take backup the database before apply the following commands.

Login as a root user

sudo su

Log into MySQL database

mysql -uroot -p

Enter MySQL root password

use koha_library;

Disable foreign key constraints when you truncate the tables


Delete all bibliographic details

TRUNCATE items; 
TRUNCATE biblioitems; 
TRUNCATE biblio; 
TRUNCATE deletedbiblioitems;
TRUNCATE deletedbiblio; 
TRUNCATE biblio_metadata;

Delete all transactions 

TRUNCATE old_issues; 
TRUNCATE issues; 

Delete borrowers details

TRUNCATE borrowers; 
TRUNCATE deletedborrowers;

Don't forget to Enable foreign key constraints when you are done



Post a Comment