Statistical mechanics of three-dimensional magnetohydrodynamics in a multiply connected domain