Solved it
Main reason to switch to this setup is to have a multi threaded approach to spam processing. sa-learn only uses one thread in a file db setup (the default of MaiB). Therefore, when 10000+ emails are processed it becomes impractical hence the move to a relational db engine. The complete change takes about 15-30 minutes.
I used the guide from Migrating spamassassin from db files to MySQL - Untimely meditations
Please find the steps adjusted for MaiB
1. Backup rules
sudo sa-learn --sync
sudo sa-learn --backup > /home/root_user/sa-learn.backup
2. Install mysql
(from guide How to Install MySQL on Ubuntu 22.04 | phoenixNAP KB)
sudo apt update
sudo apt upgrade
sudo apt install mysql-server
mysqld --version
sudo mysql_secure_installation
(please check guide for details here)
sudo systemctl status mysql
3. Configure database
sudo mysql -u root
mysql> create schema spamassassin;
Query OK, 1 row affected (0.01 sec)
mysql> create user âspamassassinâ@âlocalhostâ identified by âPasswordâ;
Query OK, 0 rows affected (0.03 sec)
mysql> grant select,insert,update,delete on spamassassin.* to âspamassassinâ@âlocalhostâ;
Query OK, 0 rows affected (0.01 sec)
mysql>exit
4. Configure tables in database
sudo mysql -u root -p spamassassin < /usr/share/doc/spamassassin/sql/bayes_mysql.sql
4b. Verify the tables (just as a precaution)
sudo mysql -u root spamassassin
mysql> show tables;
+------------------------+
| Tables_in_spamassassin |
+------------------------+
| bayes_expire |
| bayes_global_vars |
| bayes_seen |
| bayes_token |
| bayes_vars |
+------------------------+
5 rows in set (0.01 sec)
mysql> exit
5. Activate new setup in /etc/spamassassin/local.cf
Comment these
#bayes_path /home/user-data/mail/spamassassin/bayes
#bayes_file_mode 0666
Enter these lines
bayes_auto_expire 0
bayes_store_module Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn DBI:mysql:spamassassin:localhost
bayes_sql_username spamassassin
bayes_sql_password password
Restart service
sudo service spamassassin restart
6. Restore backup
sudo sa-learn --restore < /home/dit2022/sa-learn.backup