5. Find all positive integers $m, n$ such that $m^{2}+1$ is a prime number, and
$$
10\left(m^{2}+1\right)=n^{2}+1 \text {. }
$$
5. From the given condition, we have
$$
9\left(m^{2}+1\right)=(n-m)(n+m) \text {. }
$$

Notice that $m^{2}+1$ is a prime number, and $m^{2}+1 \equiv 1$ or $2(\bmod 3)$, so $m^{2}+1$ is not a multiple of 3. Therefore,
$$
\left\{\begin{array}{l}
n-m=1,3,9, m^{2}+1, \\
n+m=9\left(m^{2}+1\right), 3\left(m^{2}+1\right), m^{2}+1,9 .
\end{array}\right.
$$

Subtracting the two equations gives $9 m^{2}+8=2 m$, which is impossible.

Subtracting the two equations gives $3 m^{2}=2 m$, which is impossible.
(3) If $\left\{\begin{array}{l}n-m=9, \\ n+m=m^{2}+1\end{array}\right.$.

Subtracting the two equations gives $m^{2}-8=2 m$, so $m=4$.
(4) If $\left\{\begin{array}{l}n-m=m^{2}+1, \\ n+m=9 .\end{array}\right.$

Subtracting the two equations gives $m^{2}-8=-2 m$, so $m=2$.
When $m=2$ or 4, $m^{2}+1=5$ or 17 are both prime numbers, and the corresponding $n$ is 7 or 13.
Therefore, the pairs $(m, n)=(2,7),(4,13)$ satisfy the conditions.