It’s quite easy to chroot bind9 and apache on Debian. (See this page for bind9 and libapache2-mod-chroot or libapache2-mod-security for apache.)
But I’ve found no guide for chrooting MySQL, so here’s my short recipe:
. /etc/default/mysql-chroot
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
…
Don’t change the socket lines in the other sections!
to the [mysqld] section.
March 13th, 2005: I’ve updated the script for newer Debian packages, see Updated MySQL Chroot Script for more information.
July 30th, 2006: These modifications still work fine on the current stable Debian release (3.1, “sarge”). The mysql packages in the testing (”etch”) and unstable (”sid”) distributions of Debian need a few additional changes, I’ll post an updated guide in a few days.
December 30th, 2006: I’ve made an updated guide on how to chroot more recent MySQL packages on Debian and Ubuntu