This was performed on a Ubuntu 8.10 Intrepid Ibex install; however, it should be pretty portable.
The first step is to install the ejabberd package
sudo apt-get install ejabberd
The next thing is to download, build, and copy over the Erlang MySQL drivers.
svn co https://svn.process-one.net/ejabberd-modules/mysql/trunk mysql
cd mysql
./build.sh
sudo cp ebin/*.beam /usr/lib/ejabberd/ebin
Then, create the MySQL user for ejabberd.
mysql -u root -p
GRANT ALL ON ejabberd.* TO 'ejabberd'@'localhost' IDENTIFIED by 'password';
After creating the user, the database is created and then the table schema can be downloaded and imported.
wget http://svn.process-one.net/ejabberd/trunk/src/odbc/mysql.sql
mysql -u ejabberd -p
CREATE DATABASE ejabberd;
mysql -D ejabberd -p -u ejabberd < mysql.sql
Finally, use the following script to modify ejabberd.cfg to use MySQL (ODBC).
Script: mysqlify.sed
#!/bin/sed -f
# Modify the config for some MySQL support
# Disable internal DB
s/{auth_method, internal}/%{auth_method, internal}/
# Add DB information
/auth_method, internal/a\
\{auth_method, odbc}.\
\{odbc_server, \{mysql, "localhost", "ejabberd", "ejabberd", "password"}}.
# Replace several mods with the database equivalent
s/mod_last/mod_last_odbc/g
s/mod_offline/mod_offline_odbc/g
s/mod_roster/mod_roster_odbc/g
s/mod_vcard/mod_vcard_odbc/g
After replacing the host, database name, username, and password in the above script, run the following to modify the ejabberd config.
sudo ./mysqlify.sed /etc/ejabberd/ejabberd.cfg
Afterwards, modify ejabberd.cfg to change the default admin in the acl, admin line towards the top.
Users can be added via the following command:
sudo ejabberdctl register username server password
Make sure to restart the server when all is said and done,
sudo /etc/init.d/ejabberd restart
References:
http://sysmonblog.co.uk/2008/06/ot-installing-ejabberd-on-debian-ubuntu.html
https://support.process-one.net/doc/display/MESSENGER/Using+ejabberd+with+MySQL+native+driver