2. The minimum value of the function $f(x)=\frac{(\sin x+1)(\cos x+1)}{\sin x \cos x}$ on $\left(0, \frac{\pi}{2}\right)$ is
$$
\begin{array}{l}
f(x)=\frac{(\sin x+1)(\cos x+1)}{\sin x \cos x}=\frac{\sin x \cos x+\sin x+\cos x+1}{\sin x \cos x} \\
\xlongequal{t=\sin x+\cos x \in(1, \sqrt{2}]} \frac{\frac{t^{2}-1}{2}+t+1}{\frac{t^{2}-1}{2}}=\frac{t^{2}+2 t+1}{t^{2}-1}=\frac{t+1}{t-1}=1+\frac{2}{t-1}
\end{array}
$$
\geqslant 1+\frac{2}{\sqrt{2}-1}=3+2 \sqrt{2}, equality holds when $x=\frac{\pi}{4}$. Therefore, the minimum value of $f(x)$ is $3+2 \sqrt{2}$.