How to backup akonadi database?

depends on where the database files are. I believe mysgl is generally set-up somewhere in the users home. In which case each user would have their own copy of their own files data

If mysql is set to store the DB in a system location the files would be there and backing up the local backs all users data

I suppose it depends also on DB structure. With a proper structure it is possible to handle all user data in a single DB. E.g. you don’t need separate DBs for reach wordpress user.

However I don’t know what is the case with KDE databases and that’s why I am asking.

Yes, every user has a separate database. By default it is stored in the home directory (~/.local/share/akonadi/), if you use an external/system-wide mysql server you need to give each user a separate database or you’ll have problems.

I notice that Amarok uses a similar strategy and I am currently trying to do the same for it.

Yes, Amarok uses a mysql database to store the collection, metadata and statistics (but can write it to the actual files too).

It by default uses an internal mysql server, but can be configured to use an external/system-wide one like Akonadi (although Akonadi also supports sqlite and postgresql).
It is possible to share the Amarok database between different users, but you have to make sure that the file paths of the music files are correct in the database (i.e. it probable won’t work for files in /home/user/).
The statistics are global for all users then as well of course.

Are there any other KDE programs which can be migrated to the external mysql?

Not that I can think of at the moment.

Some do use a database for certain things, but that sqlite most of the times.
Except Kexi of course, which is a database application. It can connect to a mysql server as well and others.

Thanks for explaining wolfi.

I think I have managed to make amarok use external db. Do you have any idea which files in ~/.kde4/share/apps/amarok are safe to remove after that move?

~/.kde4/share/apps/amarok/mysqle/ contains the database files and can be deleted, ~/.kde4/share/apps/amarok/my.cnf contains the mysql configuration and is not needed any more either.

Thank you!