(1) Install everything that is needed into a VE
(2) Remove VE-specific settings, such as root password and IP address (assuming VEID is 123):
vzctl set 123 --ipdel all --save
vzctl exec 123 /usr/sbin/usermod -L root
(3) Stop the VE:
(4) Tar its private area, like this (assuming VEID is 123):
cd /vz/private/123
tar czf /vz/template/cache/fedora-core-5-i386-my_db_server.tar.gz .
(5) You can now use your new template to create more VEs:
vzctl create 456 --ostemplate fedora-core-5-i386-my_db_server
Please note that your OS template name should start with fedora-core-5, otherwise vzctl will not be able to guess how to set up networking and other parameters inside a VE. In other words, template name should start with linux distro name you use for it.
HTH