MySQL Database for Bayes
#This will allow you to set higher concurrency values and avoid file lock issues with the bayes database.
#I recommend you follow this steps for improved performance.
# UBUNTU:
apt-get install libclass-dbi-mysql-perl libclass-dbi-mysql-perl mysql-server
# CentOS
cpan -i DBI DBD::mysql
#Not sure about the package name, but if I were wrong it shouldn't be hard to find... it's mysql server after all...
yum -i mysql-server
#RESUME HERE
#You will have to enter a root password for mysql and press ENTER.
#Now access mysql
mysql -u root -p
create database bayesstore; exit
#now let's create the database scheme
cat /usr/share/doc/spamassassin/sql/bayes_mysql.sql | sed 's/MyISAM/InnoDB/g' | mysql -u root -p bayesstore
#reenter mysql and grant permissions
mysql -u root -p
#CHANGE THE PASSWORD BELOW
GRANT usage ON bayesstore.* TO bayes@localhost identified by 'CHANGEME'; GRANT SELECT, UPDATE, DELETE, INSERT ON bayesstore.bayes_token TO bayes; GRANT SELECT, UPDATE, DELETE, INSERT ON bayesstore.bayes_vars TO bayes; GRANT SELECT, DELETE, INSERT ON bayesstore.bayes_seen TO bayes; GRANT SELECT, DELETE, INSERT ON bayesstore.bayes_expire TO bayes; GRANT SELECT ON bayesstore.bayes_global_vars TO bayes;
exit
#Now we have to configure spamassassin to use mysql
echo "bayes_store_module Mail::SpamAssassin::BayesStore::MySQL" >> /etc/spamassassin/local.cf
nano /etc/spamassassin/local.cf
#AT THE END ADD:
================================================
bayes_sql_dsn DBI:mysql:bayesstore:localhost
bayes_sql_username bayes
bayes_sql_password YOURPASSWORD
=================================================
#and restart qmail and spamd
qmailctl stop
qmailctl start