Solving the equation by going into a non-UFD To solve $y^2 + 2 = x^3$ you can factor $(y - \sqrt{-2})(y + \sqrt{-2}) = x^3$ and then check that they are relatively prime and by unique factorization both must be cubes then you can solve it.
What about $y^2 + 5 = x^3$ which does not have unique factoring?

Often what matters is not whether the number ring in question is a UFD but whether its class number is relatively prime to a certain key number.  In the case of Fermat's Last Theorem, these factoring methods work well for $x^p + y^p = z^p$ for regular primes, i.e., primes for which $p$ does not divide the class number of the ring of integers of
$\mathbb{Q}(\zeta_p)$.
For the Bachet-Mordell equation $y^2 + k = x^3$ (I suppose $k$ is squarefree), the favorable case is $k \equiv 1,2 \pmod 4$ (so that $\mathbb{Z}[\sqrt{-k}]$ is the full ring of integers of $\mathbb{Q}(\sqrt{-k})$) and that the class number of $\mathbb{Q}(\sqrt{-k})$ is prime to $3$.  In the particular case $k = 5$, you're in luck: $5 \equiv 1 \pmod 4$ and the class number is $2$, which is as good as $1$!
What exactly do we win when this happens?  By some happy coincidence I wrote up some notes on precisely this: please see Theorem 7 here.  (Also see the "tables" on page 9.)
