This answer does a good job at explaining that if $I$ is primary monomial ideal in $k[x_1, \dots, x_n]$, then $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ where $m_1, \ldots, m_k$ only involve variables among $x_{i_1}, \ldots, x_{i_m}$.
However, it doesn't show that if $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ as above, then $I$ is primary.
How do we prove this?
One thing we know is that if $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ where $m_1, \ldots, m_k$ only involve variables among $x_{i_1}, \ldots, x_{i_m}$, then ${\rm rad}(I)=(x_{i_1}, \ldots, x_{i_m})$ which is prime.
As you mentioned, $\sqrt{I} = (x_{i_1}, \ldots, x_{i_m})$ is prime.
Now suppose that $ab \in I$ and that $b^n \notin I$ for all $n \in \mathbb{N}$, i.e. $b \notin \sqrt{I}$. We want to conclude that $a \in I$.
That $b \notin \sqrt{I}$ implies that $b$ has a monomial component $b_\lambda$ such that $x_{i_l} \nmid b_\lambda$ for each $1 \leq l \leq m$.
Recall that a polynomial $f$ is in a monomial ideal $J$ iff each monomial of $f$ is in the ideal $J$.
Pick a lexicographic ordering that prioritizes all of the $x_{i_l}$, $1\leq l \leq m$, over the other $x_j$. Assume WLOG that $b_\lambda$ is the monomial summand of $b$ with the lowest degree with respect to this ordering.
Now with this lexicographic ordering in mind, consider the product $ab \in I$. The contributions to the lowest degree term of the product come exclusively from $b_\lambda$ and the lowest degree term $a_\gamma$ of $a$. Thus $b_\lambda a_\gamma \in I$, and hence is a constant multiple of either $m_i$ or $x_{i_l}^{a_l}$. In either case we can deduce from $x_{i_l} \nmid b_\lambda$ that $m_i$ or $x_{i_l}^{a_l}$, respectively, divides $a_\gamma$. Thus $a_\gamma \in I$, and we can iterate the reasoning on the product $(a - a_\gamma)b \in I$ and so on to conclude that every monomial term of $a$ is in $I$, thus $a \in I$.