  Flajolet and Salvy pointed out that every Euler sum is a $\mathbb{Q}$-linear
combination of multiple zeta values. However, in the literature, there is no
formula completely revealing this relation. In this paper, using permutations
and compositions, we establish two explicit formulas for the Euler sums, and
show that all the Euler sums are indeed expressible in terms of MZVs. Moreover,
we apply this method to the alternating Euler sums, and show that all the
alternating Euler sums are reducible to alternating MZVs. Some famous results,
such as the Euler theorem, the Borwein--Borwein--Girgensohn theorems, and the
Flajolet--Salvy theorems can be obtained directly from our theory. Some other
special cases, such as the explicit expressions of $S_{r^m,q}$,
$S_{r^m,\bar{q}}$, $S_{\bar{r}^m,q}$ and $S_{\bar{r}^m,\bar{q}}$, are also
presented here. The corresponding Maple programs are developed to help us
compute all the sums of weight $w\leq 11$ for non-alternating case and of
weight $w\leq 6$ for alternating case.
