Example 6 Find all integer pairs $(m, n)$ such that
$$\left\{\begin{array}{l}
2 m \equiv-1(\bmod n), \\
n^{2} \equiv-2(\bmod m) .
\end{array}\right.$$
This problem is formally about divisibility, but in essence, it is about solving indeterminate equations.

Using the conditions $n|(2 m+1), m|\left(n^{2}+2\right)$, we know that $n, m$ are both odd numbers. If $(m, n)$ meets the requirements, then $(m, -n)$ also meets them, so we can assume $n$ is a positive odd number.

Now, let $2 m+1=a n, n^{2}+2=b m$, then $a, b$ are also odd numbers. Eliminating $n$ from the two equations, we get
$$a^{2} b m=a^{2}\left(n^{2}+2\right)=(a n)^{2}+2 a^{2}=(2 m+1)^{2}+2 a^{2},$$

which is
$$2 a^{2}+1=m\left(a^{2} b-4 m-4\right)$$

If $a= \pm 1$, then $m(b-4 m-4)=3$, so $(m, b-4 m-4)=$ $( \pm 1, \pm 3)$ or $( \pm 3, \pm 1)$, which respectively yield all solutions $(m, n, a, b)=(3, \pm 7, \pm 1,17),(1, \pm 3, \pm 1,11),(-1, \mp 1, \pm 1,-3)$ or $(-3, \mp 5, \pm 1,-9)$.

Similarly, for $a= \pm 3$, the solutions to (5) are $(m, n, a, b)=(19, \pm 13, \pm 3,9)$ or $(1, \pm 1, \pm 3,3)$.

On the other hand, eliminating $m$, we get
$$2 n^{2}+4=2 b m=a b n-b$$

Let $k=a b-2 n$, then $k$ is an odd number. From (6), we know $n=\frac{1}{k}(b+4)$, and substituting back into (6), we get
$$\begin{aligned}
& \frac{2(b+4)^{2}}{k^{2}}+4=\frac{a b(b+4)}{k}-b \\
\Rightarrow & k a=\frac{1}{b(b+4)}\left(2(b+4)^{2}+4 k^{2}+b k^{2}\right)=2+\frac{k^{2}+8}{b}
\end{aligned}$$

If $k= \pm 1$, then from (7), $\pm a=2+\frac{9}{b}$. There are three solutions, which are $(m, n, a, b)=(17, \pm 7, \pm 5,3),(27, \pm 5, \pm 1,1)$ or $(-11, \pm 3, \mp 7,-1)$. Similarly, for $k= \pm 3, \pm 5$, the new solutions are $(m, n, a, b)=(-3, \pm 1, \mp 5,-1)$ and $(3, \pm 1, \pm 7,-1)$.

Now, consider the case where $|a| \geqslant 5$ and $|k| \geqslant 7$. From (7), we know $b=\frac{k^{2}+8}{a k-2}$, and combining with $n=\frac{1}{k}(b+4)$, we get $n=\frac{k+4 a}{a k-2}$. Since $n$ is odd, we should have
$$|a k-2| \leqslant|k+4 a|$$

If $a, k$ have different signs, then
$$\begin{array}{l}
|a k-2|=|a k|+2>\max \{|k|,|4 a|\} \\
>\max \{|k|-4|a|, 4|a|-k\}=|k+4 a|
\end{array}$$

which contradicts (8).
If $a, k$ have the same sign, then
$$\begin{aligned}
|a k-2| & =|a k|-2=4|a|+|k|+(|a|-1)(|k|-1)-6 \\
& \geqslant 4|a|+|k|+4 \times 6-6>4|a|+|k|=|k+4 a|
\end{aligned}$$

which also contradicts (8).
In summary, the integer pairs $(m, n)$ that satisfy the conditions are $(27, \pm 5),(19, \pm 13),(17$,
$$\begin{array}{l} 
\pm 7),(3, \pm 1),(3, \pm 7),(1, \pm 1),(1, \pm 3),(-1, \pm 1),(-3, \pm 1) \\
(-3, \pm 5) \text { or }(-11, \pm 3) .
\end{array}$$