Having recently set up Asterisk, I was a little unhappy about the default installation of a MySQL server on the trixbox server and creating the databases there.

I have a separate MySQL server (with phpMyAdmin) and I didn’t want to have to think about backing up and maintaining another one, so I did a bit of Googling to find out how to migrate FreePBX or trixbox databases to another server.

The results were a little disappointing, with only vague references about how to go about doing it, and they seem to discourage it. Boring!

Here is what I did:

From what I can see, there are five databases that trixbox uses:

  • asterisk
  • asteriskcdrdb
  • asteriskrealtime
  • meetme
  • endpoints

A quick mysqldump will take care of these:

mysqldump -p -uroot --database asterisk \

asteriskcdrdb asteriskrealtime meetme \
endpoints > backup.sql

You will be asked for your trixbox MySQL root password (default is passw0rd).

Then copy the resulting SQL dump file to the database server:

scp backup.sql user@mysqlserver:

And stop MySQL on the trixbox server:

/etc/init.d/mysqld stop

Prevent it restarting:

chkconfig --level 345 mysqld off

Then change all references to localhost or 127.0.0.1 in the following files to point at your MySQL server. If you haven’t already changed the default password for asteriskuser, then choose one now and edit is as well:

  • /etc/amportal.conf (references asterisk database)
  • /etc/asterisk/cdr_mysql.conf (references asteriskcdrdb database)
  • /etc/asterisk/res_mysql.conf (references asteriskrealtime database)
  • /etc/asterisk/cbmysql.conf (references meetme database)

The eagle-eyed will notice that I haven’t changed the reference to the endpoints database. I don’t use this and I can’t find a reference to it. Can you?!?

Now on the MySQL server:

mysql -p -uroot < backup.sql

You will be asked for your MySQL root password.

Then pop into phpMyAdmin and create the asteriskuser user with the same password as was used on the trixbox server (I had already changed this from the default and updated the above conf files). Do not assign any default privileges.

Once the user is created, assign ALL PRIVILEGES (i.e. Check all except Grant) to the five databases listed above using the Database-specific privileges box.

All that remains is to restart Asterisk on the trixbox server and you are done.

/etc/init.d/asterisk restart

I hope that this helps you. Please leave feedback using the comments.

One Response to “Running trixbox databases on a different server”

  1. Thanks, this helped change my passwords on my trixbox from the default ones to more secure ones. I am also keeping this in my hat for another day :P

    R

    December 15th, 2008 | 7:46 am

Leave a Reply