An Anti-Spam gateway #8: MySQL and SpamAssassin

(NOTE: this is part of the “An Anti-Spam gateway” series)

Thought I’d forgotten about this one, didn’t you? :)

Ready to make SpamAssassin actually use MySQL for the bayes database?

Start by creating the database itself:

mysql
CREATE DATABASE bayes;
GRANT ALL PRIVILEGES on bayes.* TO bayes@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES on bayes.* TO bayes@10.0.0.1 IDENTIFIED BY 'password';
EXIT

changing password to something else, of course

Next, I know you’ve already installed SpamAssassin using CPAN, but go to www.spamassassin.org and download it manually; you’ll be needing a file from the distribution, and while it should still be in /root/.CPAN, it’s simpler this way. Uncompress the .tar.gz and go to the sql/ directory. Then type:

mysql -u bayes -p < bayes_mysql.sql

It’ll ask for a password, which is the one you used when creating the database.

Now, edit the file /etc/mail/spamassassin/local.cf. Add the following lines:

bayes_store_module Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn DBI:mysql:bayes:localhost
bayes_sql_username bayes
bayes_sql_password password

(again, replace password with the proper one.)

SpamAssassin is now configured to store bayes data on MySQL. Wasn’t too hard, was it? :)

Related posts:

  1. An Anti-Spam gateway #0: Introduction
  2. An Anti-Spam gateway #7: MySQL
  3. An Anti-Spam gateway #5: SpamAssassin
  4. An Anti-Spam gateway #6: Razor
  5. An Anti-Spam gateway #1: Initial stuff

0 Responses to “An Anti-Spam gateway #8: MySQL and SpamAssassin”


  1. No Comments

Leave a Reply




Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal
Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal