Koha Check-In Not Working? Here’s a Quick Database Fix
If your Koha library management system is showing issues during book check-ins—such as transactions getting stuck or error messages appearing—you might be dealing with a database auto increment problem. This is a known issue, especially on systems running MySQL or MariaDB, where Koha fails to assign new IDs properly due to duplicated or undeleted entries.
Until a permanent fix is available, follow this step-by-step guide to clean your database and resolve check-in failures.
Common Symptoms of Auto Increment Errors in Koha
- Book check-in fails or hangs.
- Repeated error messages on circulation screens.
- Duplicate entries in
deletedbiblio
,deleteditems
, orold_issues
. - Incorrect sequence values in MySQL tables.
Step 1: Access the Database
Use a terminal to log into your Koha database:
sudo mysql -uroot -p
Then, select your Koha database:
USE koha_library;
(Replace koha_library
with your actual Koha DB name.)
Step 2: Clean Faulty Entries
Delete specific problematic entries using SQL commands. Here’s how:
DELETE FROM old_issues WHERE issue_id IN (900,901,902);
DELETE FROM deletedbiblio WHERE biblionumber IN (1001,1002);
DELETE FROM deleteditems WHERE biblionumber IN (2001,2002);
DELETE FROM deletedborrowers WHERE borrowernumber IN (3001,3002);
Exit the session after cleanup:
exit;
Step 3: Configure the Init Script
Depending on your Linux distribution, open the relevant MySQL or MariaDB config file:
- Ubuntu 16.04:
/etc/mysql/my.cnf
- Ubuntu 18.04+:
/etc/mysql/mysql.conf.d/mysqld.cnf
- Debian 9/MariaDB:
/etc/mysql/mariadb.conf.d/50-server.cnf
Under [mysqld]
, add:
init-file=/var/lib/mysql/init-file_koha_library.sql
Step 4: Create Auto Increment Reset Script
Create the file:
sudo leafpad /var/lib/mysql/init-file_koha_library.sql
Paste the following (change database name if needed):
USE koha_library;
SET @borrower = (SELECT GREATEST(IFNULL(MAX(borrowernumber),0), IFNULL((SELECT MAX(borrowernumber) FROM deletedborrowers),0)) + 1);
SET @sql = CONCAT('ALTER TABLE borrowers AUTO_INCREMENT=', @borrower);
PREPARE stmt FROM @sql; EXECUTE stmt;
-- Add similar blocks for biblio, items, issues, and reserves
Save and exit.
Step 5: Restart MySQL/MariaDB
To apply the changes:
sudo service mysql restart
Final Thoughts
This fix can resolve check-in failures caused by incorrect auto increment values in Koha’s backend. Always back up your database before executing deletion queries or modifying configurations. While temporary, this solution keeps your Koha system functional until a software update provides a permanent resolution.
Credit By
Omkar Kakeru
Founder Of PlayTech