# invoke-rc.d mysql stop # mkdir -p /var/chroot/mysql/{etc,lib,lib64,tmp,usr/lib,usr/share,var/lib,var/log/mysql,var/run} # grep '^mysql:' /etc/passwd > /var/chroot/mysql/etc/passwd # cp /etc/localtime /var/chroot/mysql/etc/ # echo -e "127.0.0.1\tlocalhost\n10.1.1.201\tweb.localdomain web\n10.1.1.202\tsql.localdomain sql" > /var/chroot/mysql/etc/hosts # mv /var/lib/mysql /var/chroot/mysql/var/lib/ # ln -s /var/chroot/mysql/var/lib/mysql/ /var/lib/mysql # mv /var/run/mysqld /var/chroot/mysql/var/run/ # ln -s /var/chroot/mysql/var/run/mysqld/ /var/run/mysqld # mv /usr/share/mysql /var/chroot/mysql/usr/share/ # ln -s /var/chroot/mysql/usr/share/mysql/ /usr/share/mysql # chown mysql:mysql /var/chroot/mysql/var/lib/mysql # chown mysql:adm /var/chroot/mysql/var/log/mysql # chown mysql:root /var/chroot/mysql/var/run/mysqld # chmod 2750 /var/chroot/mysql/var/log/mysql/ # chmod 1777 /var/chroot/mysql/tmp/ # touch /var/chroot/mysql/var/log/mysql.{err,log} # chmod 640 /var/chroot/mysql/var/log/mysql.{err,log} # chown root:adm /var/chroot/mysql/var/log/mysql.err # chown mysql:adm /var/chroot/mysql/var/log/mysql.log # ldd /usr/sbin/mysqld linux-vdso.so.1 => (0x00007fffffffe000) librt.so.1 => /lib/librt.so.1 (0x00007f27d7ff7000) libz.so.1 => /usr/lib/libz.so.1 (0x00007f27d7de0000) libwrap.so.0 => /lib/libwrap.so.0 (0x00007f27d7bd7000) libdl.so.2 => /lib/libdl.so.2 (0x00007f27d79d3000) libpthread.so.0 => /lib/libpthread.so.0 (0x00007f27d77b7000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f27d757f000) libnsl.so.1 => /lib/libnsl.so.1 (0x00007f27d7367000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f27d705b000) libm.so.6 => /lib/libm.so.6 (0x00007f27d6dd8000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f27d6bc1000) libc.so.6 => /lib/libc.so.6 (0x00007f27d686e000) /lib64/ld-linux-x86-64.so.2 (0x00007f27d8200000) # cp /lib64/ld-linux-x86-64.so.2 /var/chroot/mysql/lib64/ # cp /usr/lib/libz.so.1 /usr/lib/libstdc++.so.6 /var/chroot/mysql/usr/lib/ # cp /lib/librt.so.1 /lib/libwrap.so.0 /lib/libdl.so.2 /lib/libpthread.so.0 /lib/libcrypt.so.1 /lib/libnsl.so.1 /lib/libm.so.6 /lib/libgcc_s.so.1 /lib/libc.so.6 /var/chroot/mysql/lib/ # vim /etc/mysql/debian.cnf socket = /var/chroot/mysql/var/run/mysqld/mysqld.sock # vim /etc/mysql/my.cnf [client] socket = /var/chroot/mysql/var/run/mysqld/mysqld.sock [mysqld] chroot = /var/chroot/mysql/ # invoke-rc.d mysql start |